@audienti/cli 0.1.145 → 0.2.0-exora.2

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 (66) hide show
  1. package/README.md +47 -895
  2. package/bin/audienti-mcp.mjs +2 -0
  3. package/cli/account-intake-operations.mjs +28 -0
  4. package/cli/account-intake.mjs +33 -0
  5. package/cli/account-replies.mjs +35 -0
  6. package/cli/account-reply-operations.mjs +30 -0
  7. package/cli/agents.mjs +107 -0
  8. package/cli/approach-operations.mjs +22 -0
  9. package/cli/assignment-operations.mjs +218 -0
  10. package/cli/assignment.mjs +116 -0
  11. package/cli/audience-operations.mjs +16 -0
  12. package/cli/audiences.mjs +26 -0
  13. package/cli/audienti.mjs +124 -0
  14. package/cli/connection-registry-operations.mjs +7 -0
  15. package/cli/content.mjs +29 -0
  16. package/cli/discovery-operations.mjs +27 -0
  17. package/cli/discovery.mjs +14 -0
  18. package/cli/experiment-operations.mjs +25 -0
  19. package/cli/experiments.mjs +26 -0
  20. package/cli/json-file.mjs +13 -0
  21. package/cli/mcp.mjs +47 -0
  22. package/cli/offer-operations.mjs +12 -0
  23. package/cli/offers.mjs +24 -0
  24. package/cli/owner-account-client.mjs +18 -0
  25. package/cli/profiles.mjs +29 -0
  26. package/cli/progress.mjs +12 -0
  27. package/cli/prospecting-settings-operations.mjs +16 -0
  28. package/cli/prospecting-settings.mjs +15 -0
  29. package/cli/recipient-operations.mjs +13 -0
  30. package/cli/recipients.mjs +30 -0
  31. package/cli/sender-account-operations.mjs +24 -0
  32. package/cli/sender-accounts.mjs +23 -0
  33. package/cli/skills-mcp.mjs +24 -0
  34. package/cli/skills.mjs +56 -0
  35. package/cli/suppression-operations.mjs +8 -0
  36. package/cli/suppression.mjs +12 -0
  37. package/cli/tools-operations.mjs +70 -0
  38. package/cli/tools.mjs +72 -0
  39. package/cli/work-execution-operations.mjs +35 -0
  40. package/cli/work-execution.mjs +29 -0
  41. package/cli/work-feedback-operations.mjs +17 -0
  42. package/cli/work-feedback.mjs +18 -0
  43. package/cli/work-operations.mjs +28 -0
  44. package/cli/work.mjs +27 -0
  45. package/cli/workspaces.mjs +158 -0
  46. package/package.json +15 -26
  47. package/skills/audienti/SKILL.md +61 -323
  48. package/skills/audienti/references/helpers.md +149 -0
  49. package/skills/audienti/references/profile-workflows.md +212 -0
  50. package/skills/audienti/references/workflow-receipt.md +49 -0
  51. package/skills/audienti/scripts/contracts.mjs +72 -0
  52. package/skills/audienti/scripts/profile-helpers.mjs +138 -0
  53. package/skills/audienti/scripts/run.mjs +40 -0
  54. package/source-manifest.json +60 -0
  55. package/.mcp.json +0 -13
  56. package/CHANGELOG.md +0 -1018
  57. package/bin/audienti-mcp.js +0 -5
  58. package/bin/audienti.js +0 -6
  59. package/install +0 -83
  60. package/skills/audienti/references/methodology.md +0 -111
  61. package/skills/audienti-gift-research/SKILL.md +0 -47
  62. package/src/agent-skills.js +0 -60
  63. package/src/api-client.js +0 -1639
  64. package/src/cli.js +0 -16992
  65. package/src/config.js +0 -130
  66. package/src/mcp.js +0 -103
package/src/config.js DELETED
@@ -1,130 +0,0 @@
1
- import { chmod, mkdir, readFile, rename, rm, unlink, writeFile } from "node:fs/promises";
2
- import { dirname, join } from "node:path";
3
- import { homedir } from "node:os";
4
-
5
- const CONFIG_FILENAME = "config.json";
6
- const ACCOUNT_CONFIG_KEYS = ["accountId", "accountName", "accountUserId", "accountUserName", "accountUserEmail"];
7
-
8
- export class ConfigError extends Error {
9
- constructor(message) {
10
- super(message);
11
- this.name = "ConfigError";
12
- }
13
- }
14
-
15
- export function configDirectory(env = process.env) {
16
- return env.AUDIENTI_CONFIG_HOME || join(homedir(), ".config", "audienti");
17
- }
18
-
19
- export function configPath(env = process.env) {
20
- return join(configDirectory(env), CONFIG_FILENAME);
21
- }
22
-
23
- export function fallbackConfigDirectory(env = process.env) {
24
- return env.AUDIENTI_CONFIG_FALLBACK_HOME || null;
25
- }
26
-
27
- export function fallbackConfigPath(env = process.env) {
28
- const directory = fallbackConfigDirectory(env);
29
- return directory ? join(directory, CONFIG_FILENAME) : null;
30
- }
31
-
32
- export async function readConfig({ env = process.env } = {}) {
33
- const config = await readConfigFile(configPath(env));
34
- const fallbackPath = fallbackConfigPath(env);
35
- if (!fallbackPath || fallbackPath === configPath(env)) return applyConfigOverrides(config, env);
36
-
37
- const fallbackConfig = await readConfigFile(fallbackPath);
38
- return applyConfigOverrides(mergeFallbackConfig(config, fallbackConfig), env);
39
- }
40
-
41
- async function readConfigFile(filePath) {
42
-
43
- try {
44
- return JSON.parse(await readFile(filePath, "utf8"));
45
- } catch (error) {
46
- if (error.code === "ENOENT") return {};
47
- if (error instanceof SyntaxError) {
48
- throw new ConfigError(`Config file is invalid JSON: ${filePath}`);
49
- }
50
-
51
- throw error;
52
- }
53
- }
54
-
55
- function mergeFallbackConfig(config, fallbackConfig) {
56
- const merged = { ...config };
57
-
58
- if (!merged.host && !merged.token && fallbackConfig.host && fallbackConfig.token) {
59
- merged.host = fallbackConfig.host;
60
- merged.token = fallbackConfig.token;
61
- }
62
-
63
- if (!merged.accountId && fallbackConfig.accountId) {
64
- for (const key of ACCOUNT_CONFIG_KEYS) {
65
- if (fallbackConfig[key]) merged[key] = fallbackConfig[key];
66
- }
67
- } else if (merged.accountId && merged.accountId === fallbackConfig.accountId) {
68
- for (const key of ACCOUNT_CONFIG_KEYS) {
69
- if (!merged[key] && fallbackConfig[key]) merged[key] = fallbackConfig[key];
70
- }
71
- }
72
-
73
- return merged;
74
- }
75
-
76
- function applyConfigOverrides(config, env) {
77
- if (!env.AUDIENTI_CONFIG_HOST_OVERRIDE) return config;
78
-
79
- const overridden = {
80
- ...config,
81
- host: env.AUDIENTI_CONFIG_HOST_OVERRIDE
82
- };
83
- if (config.token && !sameCredentialOrigin(config.host, overridden.host)) delete overridden.token;
84
-
85
- return overridden;
86
- }
87
-
88
- function sameCredentialOrigin(left, right) {
89
- if (!left || !right) return false;
90
-
91
- try {
92
- return new URL(left).origin === new URL(right).origin;
93
- } catch {
94
- return String(left).replace(/\/+$/, "") === String(right).replace(/\/+$/, "");
95
- }
96
- }
97
-
98
- export async function writeConfig(config, { env = process.env } = {}) {
99
- const filePath = configPath(env);
100
- const dir = dirname(filePath);
101
- const tempPath = join(dir, `.config-${process.pid}-${Date.now()}.tmp`);
102
-
103
- await mkdir(dir, { recursive: true, mode: 0o700 });
104
- await chmod(dir, 0o700);
105
-
106
- try {
107
- await writeFile(tempPath, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
108
- await chmod(tempPath, 0o600);
109
- await rename(tempPath, filePath);
110
- await chmod(filePath, 0o600);
111
- } catch (error) {
112
- await rm(tempPath, { force: true }).catch(() => {});
113
- throw error;
114
- }
115
- }
116
-
117
- export async function deleteConfig({ env = process.env } = {}) {
118
- try {
119
- await unlink(configPath(env));
120
- } catch (error) {
121
- if (error.code !== "ENOENT") throw error;
122
- }
123
- }
124
-
125
- export function maskToken(token) {
126
- const value = String(token || "");
127
- if (value.length <= 8) return "********";
128
-
129
- return `${value.slice(0, 4)}...${value.slice(-4)}`;
130
- }
package/src/mcp.js DELETED
@@ -1,103 +0,0 @@
1
- import { ApiError, AudientiClient, DEFAULT_HOST } from "./api-client.js";
2
- import { readConfig } from "./config.js";
3
-
4
- export async function runMcpServer({
5
- input = process.stdin,
6
- output = process.stdout,
7
- env = process.env,
8
- fetchImpl = globalThis.fetch
9
- } = {}) {
10
- input.setEncoding("utf8");
11
-
12
- let buffer = "";
13
- for await (const chunk of input) {
14
- buffer += chunk;
15
- const lines = buffer.split(/\r?\n/);
16
- buffer = lines.pop() || "";
17
-
18
- for (const line of lines) {
19
- if (!line.trim()) continue;
20
- const response = await handleRawMessage(line, { env, fetchImpl });
21
- if (response) output.write(`${JSON.stringify(response)}\n`);
22
- }
23
- }
24
- }
25
-
26
- export async function handleRawMessage(line, options = {}) {
27
- try {
28
- return handleMcpRequest(JSON.parse(line), options);
29
- } catch (error) {
30
- return errorResponse(null, -32700, error.message);
31
- }
32
- }
33
-
34
- export async function handleMcpRequest(message, { env = process.env, fetchImpl = globalThis.fetch } = {}) {
35
- if (!message || message.jsonrpc !== "2.0") {
36
- return errorResponse(message?.id ?? null, -32600, "Invalid JSON-RPC request.");
37
- }
38
-
39
- if (message.id === undefined || message.id === null) return null;
40
-
41
- try {
42
- return await remoteMcpResponse(message, { env, fetchImpl });
43
- } catch (error) {
44
- return errorResponse(message.id, -32603, toolErrorMessage(error), toolErrorPayload(error));
45
- }
46
- }
47
-
48
- async function remoteMcpResponse(message, { env = process.env, fetchImpl = globalThis.fetch } = {}) {
49
- const config = await readConfig({ env });
50
- if (!config.token) throw new Error("Not authenticated. Run `audienti auth login` or `audienti auth token <token>`.");
51
-
52
- const client = new AudientiClient({
53
- host: config.host || DEFAULT_HOST,
54
- token: config.token,
55
- fetchImpl
56
- });
57
-
58
- return client.mcp(withSelectedAccount(message, config));
59
- }
60
-
61
- function withSelectedAccount(message, config) {
62
- if (message.method !== "tools/call" || !config.accountId) return message;
63
-
64
- const params = message.params || {};
65
- const args = params.arguments || {};
66
- if (args.account_id) return message;
67
-
68
- return {
69
- ...message,
70
- params: {
71
- ...params,
72
- arguments: {
73
- ...args,
74
- account_id: config.accountId
75
- }
76
- }
77
- };
78
- }
79
-
80
- function errorResponse(id, code, message, data) {
81
- return {
82
- jsonrpc: "2.0",
83
- id,
84
- error: {
85
- code,
86
- message,
87
- ...(data === undefined ? {} : { data })
88
- }
89
- };
90
- }
91
-
92
- function toolErrorMessage(error) {
93
- if (error instanceof ApiError && error.status) return `${error.message} (HTTP ${error.status})`;
94
- return error.message;
95
- }
96
-
97
- function toolErrorPayload(error) {
98
- return {
99
- error: error.message,
100
- status: error instanceof ApiError ? error.status || null : null,
101
- body: error instanceof ApiError ? error.body || null : null
102
- };
103
- }