elizaos-plugin-crewpay 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.
package/README.md CHANGED
@@ -23,11 +23,10 @@ import crewpayPlugin from 'elizaos-plugin-crewpay'
23
23
 
24
24
  ## Safety
25
25
 
26
- - Always run `CREW_LAUNCH_DRY_RUN` first — it returns a `dryRunToken`
27
- - `CREW_LAUNCH` requires `dryRunToken` + `humanConfirmed: true` + `confirmPhrase: "APPROVE_SOL_SPEND"` (human-supplied)
28
- - `CREW_WIRE_FEES` also requires `humanConfirmed` + `APPROVE_SOL_SPEND`
26
+ - Always run `CREW_LAUNCH_DRY_RUN` first — it returns `dryRunId` + `approvalUrl`
27
+ - Human opens `approvalUrl`; then `CREW_LAUNCH` with the same body + `dryRunId`
29
28
  - Fee map: **60% KOLs / 15% agent / 25% CrewPay** — buyback cron not live yet
30
- - Prefer MCP: `npx -y crewpay-mcp@1.2.1` or https://mcp.crewpay.dev/mcp
29
+ - Prefer MCP: `npx -y crewpay-mcp@1.2.3` or https://mcp.crewpay.dev/mcp
31
30
 
32
31
  ## Links
33
32
 
package/dist/client.d.ts CHANGED
@@ -2,21 +2,17 @@
2
2
  * Minimal CrewPay REST client for framework plugins.
3
3
  * Keys from env only — never accept private keys as function arguments.
4
4
  *
5
- * Spend gates: dry-run issues a short-lived dryRunToken; launch/wire require that
6
- * token (launch) plus the exact confirmPhrase APPROVE_SOL_SPEND (not a free-form
7
- * boolean the model can invent from chat alone).
5
+ * Spend gate: POST /api/agent/launch/dry-run returns dryRunId + approvalUrl
6
+ * (no approve secret). Operator opens approvalUrl and wallet-signs.
7
+ * Launch/wire require dryRunId after approval. Image content is bound by sha256.
8
8
  */
9
9
  export declare const DEFAULT_API_URL = "https://api.crewpay.dev";
10
- /** Exact phrase a human must supply for SOL-spending calls. */
11
- export declare const SOL_SPEND_CONFIRM_PHRASE = "APPROVE_SOL_SPEND";
12
10
  export type CrewPayEnv = {
13
11
  apiUrl?: string;
14
12
  apiKey?: string;
15
13
  launcherKey?: string;
16
14
  };
17
15
  export declare function loadCrewPayEnv(overrides?: CrewPayEnv): Required<Pick<CrewPayEnv, 'apiUrl'>> & CrewPayEnv;
18
- /** Canonical hash of launch fields so dry-run and launch bodies must match. */
19
- export declare function hashLaunchBody(body: Record<string, unknown>): string;
20
16
  export declare class CrewPayClient {
21
17
  private readonly env;
22
18
  constructor(env?: ReturnType<typeof loadCrewPayEnv>);
@@ -32,27 +28,19 @@ export declare class CrewPayClient {
32
28
  model?: string;
33
29
  }): Promise<unknown>;
34
30
  autohire(body: Record<string, unknown>): Promise<unknown>;
35
- dryRun(body: Record<string, unknown>): Promise<{
36
- dryRunToken: string;
37
- confirmPhraseRequired: string;
38
- tip: string;
39
- }>;
40
- /**
41
- * Real launch — spends SOL. Requires a prior dryRunToken for this body plus
42
- * humanConfirmed and confirmPhrase APPROVE_SOL_SPEND.
43
- */
31
+ /** Server dry-run — returns plan + dryRunId + approvalUrl (no approve secret). */
32
+ dryRun(body: Record<string, unknown>): Promise<unknown>;
44
33
  launch(body: Record<string, unknown>, opts: {
45
- humanConfirmed: boolean;
46
- confirmPhrase: string;
47
- dryRunToken: string;
34
+ dryRunId: string;
48
35
  }): Promise<unknown>;
49
36
  wireFees(body: {
50
37
  mint: string;
51
38
  mode?: string;
52
39
  crew?: unknown[];
40
+ name?: string;
41
+ ticker?: string;
53
42
  }, opts: {
54
- humanConfirmed: boolean;
55
- confirmPhrase: string;
43
+ dryRunId: string;
56
44
  }): Promise<unknown>;
57
45
  crank(body: {
58
46
  mint: string;
package/dist/client.js CHANGED
@@ -2,16 +2,11 @@
2
2
  * Minimal CrewPay REST client for framework plugins.
3
3
  * Keys from env only — never accept private keys as function arguments.
4
4
  *
5
- * Spend gates: dry-run issues a short-lived dryRunToken; launch/wire require that
6
- * token (launch) plus the exact confirmPhrase APPROVE_SOL_SPEND (not a free-form
7
- * boolean the model can invent from chat alone).
5
+ * Spend gate: POST /api/agent/launch/dry-run returns dryRunId + approvalUrl
6
+ * (no approve secret). Operator opens approvalUrl and wallet-signs.
7
+ * Launch/wire require dryRunId after approval. Image content is bound by sha256.
8
8
  */
9
- import { createHash, randomBytes } from 'node:crypto';
10
9
  export const DEFAULT_API_URL = 'https://api.crewpay.dev';
11
- /** Exact phrase a human must supply for SOL-spending calls. */
12
- export const SOL_SPEND_CONFIRM_PHRASE = 'APPROVE_SOL_SPEND';
13
- const pendingDryRuns = new Map();
14
- const DRY_RUN_TTL_MS = 30 * 60 * 1000;
15
10
  export function loadCrewPayEnv(overrides = {}) {
16
11
  return {
17
12
  apiUrl: (overrides.apiUrl || process.env.CREW_API_URL || DEFAULT_API_URL).replace(/\/$/, ''),
@@ -24,29 +19,6 @@ export function loadCrewPayEnv(overrides = {}) {
24
19
  '',
25
20
  };
26
21
  }
27
- /** Canonical hash of launch fields so dry-run and launch bodies must match. */
28
- export function hashLaunchBody(body) {
29
- const pick = {
30
- name: body.name,
31
- ticker: body.ticker,
32
- description: body.description ?? null,
33
- mode: body.mode ?? 'agent',
34
- initialBuySol: body.initialBuySol ?? 0,
35
- imageUrl: body.imageUrl ?? null,
36
- autoHire: body.autoHire ?? null,
37
- crew: body.crew ?? null,
38
- holderKol: body.holderKol ?? false,
39
- };
40
- return createHash('sha256').update(JSON.stringify(pick)).digest('hex');
41
- }
42
- function assertSpendConfirm(opts, action) {
43
- if (opts.humanConfirmed !== true) {
44
- throw new Error(`${action} blocked: humanConfirmed must be true after an explicit human approval`);
45
- }
46
- if (opts.confirmPhrase !== SOL_SPEND_CONFIRM_PHRASE) {
47
- throw new Error(`${action} blocked: confirmPhrase must be exactly "${SOL_SPEND_CONFIRM_PHRASE}" (human-supplied; do not invent)`);
48
- }
49
- }
50
22
  export class CrewPayClient {
51
23
  env;
52
24
  constructor(env = loadCrewPayEnv()) {
@@ -102,52 +74,36 @@ export class CrewPayClient {
102
74
  body: JSON.stringify(body),
103
75
  });
104
76
  }
105
- async dryRun(body) {
106
- const data = await this.fetch('/api/agent/launch/dry-run', {
77
+ /** Server dry-run — returns plan + dryRunId + approvalUrl (no approve secret). */
78
+ dryRun(body) {
79
+ return this.fetch('/api/agent/launch/dry-run', {
107
80
  method: 'POST',
108
81
  auth: true,
109
82
  body: JSON.stringify(body),
110
83
  });
111
- const dryRunToken = randomBytes(16).toString('hex');
112
- pendingDryRuns.set(dryRunToken, {
113
- bodyHash: hashLaunchBody(body),
114
- expiresAt: Date.now() + DRY_RUN_TTL_MS,
115
- });
116
- return {
117
- ...(typeof data === 'object' && data ? data : { result: data }),
118
- dryRunToken,
119
- confirmPhraseRequired: SOL_SPEND_CONFIRM_PHRASE,
120
- tip: `To launch: pass the same body + dryRunToken + humanConfirmed:true + confirmPhrase:"${SOL_SPEND_CONFIRM_PHRASE}" (human must supply the phrase).`,
121
- };
122
84
  }
123
- /**
124
- * Real launch — spends SOL. Requires a prior dryRunToken for this body plus
125
- * humanConfirmed and confirmPhrase APPROVE_SOL_SPEND.
126
- */
127
85
  launch(body, opts) {
128
- assertSpendConfirm(opts, 'Launch');
129
- const pending = pendingDryRuns.get(opts.dryRunToken);
130
- if (!pending || pending.expiresAt < Date.now()) {
131
- throw new Error('Launch blocked: missing/expired dryRunToken — call dryRun first and reuse its dryRunToken');
132
- }
133
- if (pending.bodyHash !== hashLaunchBody(body)) {
134
- throw new Error('Launch blocked: body does not match the dry-run that issued dryRunToken');
86
+ const dryRunId = String(opts.dryRunId || '').trim();
87
+ if (!dryRunId) {
88
+ throw new Error('Launch blocked: dryRunId required — dry-run, operator wallet-approves on approvalUrl, then launch');
135
89
  }
136
- pendingDryRuns.delete(opts.dryRunToken);
137
90
  return this.fetch('/api/agent/launch', {
138
91
  method: 'POST',
139
92
  auth: true,
140
93
  launcher: true,
141
- body: JSON.stringify(body),
94
+ body: JSON.stringify({ ...body, dryRunId }),
142
95
  });
143
96
  }
144
97
  wireFees(body, opts) {
145
- assertSpendConfirm(opts, 'Wire-fees');
98
+ const dryRunId = String(opts.dryRunId || '').trim();
99
+ if (!dryRunId) {
100
+ throw new Error('Wire-fees blocked: dryRunId required — dry-run with intent=wire-fees, wallet-approve, then wire');
101
+ }
146
102
  return this.fetch('/api/agent/wire-fees', {
147
103
  method: 'POST',
148
104
  auth: true,
149
105
  launcher: true,
150
- body: JSON.stringify(body),
106
+ body: JSON.stringify({ ...body, dryRunId }),
151
107
  });
152
108
  }
153
109
  crank(body) {
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * ElizaOS plugin scaffold for CrewPay.
3
- * Docs: https://docs.elizaos.ai/plugins/development
3
+ * Prefer MCP: npx -y crewpay-mcp@1.2.3 or https://mcp.crewpay.dev/mcp
4
4
  *
5
- * Env: CREWPAY_API_KEY (or CREW_AGENT_API_KEY), optional CREW_LAUNCHER_KEY (burner), CREW_API_URL.
6
- * Launch/wire require dryRunToken (from dry-run) + confirmPhrase APPROVE_SOL_SPEND + humanConfirmed.
5
+ * Launch requires dryRunId from CREW_LAUNCH_DRY_RUN after human approval
6
+ * on the approvalUrl page (no confirm phrase).
7
7
  */
8
- type ActionResult = {
9
- success: boolean;
10
- text?: string;
11
- data?: unknown;
12
- error?: string;
13
- };
14
8
  export declare const crewDiscoverAction: {
15
9
  name: string;
16
10
  similes: string[];
17
11
  description: string;
18
12
  validate: () => Promise<boolean>;
19
- handler: () => Promise<ActionResult>;
13
+ handler: () => Promise<{
14
+ success: boolean;
15
+ data: unknown;
16
+ } | {
17
+ success: boolean;
18
+ error: string;
19
+ }>;
20
20
  };
21
21
  export declare const crewAutohireAction: {
22
22
  name: string;
@@ -27,7 +27,13 @@ export declare const crewAutohireAction: {
27
27
  content?: {
28
28
  text?: string;
29
29
  };
30
- }) => Promise<ActionResult>;
30
+ }) => Promise<{
31
+ success: boolean;
32
+ data: unknown;
33
+ } | {
34
+ success: boolean;
35
+ error: string;
36
+ }>;
31
37
  };
32
38
  export declare const crewDryRunAction: {
33
39
  name: string;
@@ -38,7 +44,13 @@ export declare const crewDryRunAction: {
38
44
  content?: {
39
45
  text?: string;
40
46
  };
41
- }) => Promise<ActionResult>;
47
+ }) => Promise<{
48
+ success: boolean;
49
+ data: unknown;
50
+ } | {
51
+ success: boolean;
52
+ error: string;
53
+ }>;
42
54
  };
43
55
  export declare const crewLaunchAction: {
44
56
  name: string;
@@ -49,7 +61,13 @@ export declare const crewLaunchAction: {
49
61
  content?: {
50
62
  text?: string;
51
63
  };
52
- }) => Promise<ActionResult>;
64
+ }) => Promise<{
65
+ success: boolean;
66
+ data: unknown;
67
+ } | {
68
+ success: boolean;
69
+ error: string;
70
+ }>;
53
71
  };
54
72
  export declare const crewWireFeesAction: {
55
73
  name: string;
@@ -60,7 +78,13 @@ export declare const crewWireFeesAction: {
60
78
  content?: {
61
79
  text?: string;
62
80
  };
63
- }) => Promise<ActionResult>;
81
+ }) => Promise<{
82
+ success: boolean;
83
+ data: unknown;
84
+ } | {
85
+ success: boolean;
86
+ error: string;
87
+ }>;
64
88
  };
65
89
  export declare const crewCrankAction: {
66
90
  name: string;
@@ -71,14 +95,26 @@ export declare const crewCrankAction: {
71
95
  content?: {
72
96
  text?: string;
73
97
  };
74
- }) => Promise<ActionResult>;
98
+ }) => Promise<{
99
+ success: boolean;
100
+ data: unknown;
101
+ } | {
102
+ success: boolean;
103
+ error: string;
104
+ }>;
75
105
  };
76
106
  export declare const crewProofAction: {
77
107
  name: string;
78
108
  similes: string[];
79
109
  description: string;
80
110
  validate: () => Promise<boolean>;
81
- handler: () => Promise<ActionResult>;
111
+ handler: () => Promise<{
112
+ success: boolean;
113
+ data: unknown;
114
+ } | {
115
+ success: boolean;
116
+ error: string;
117
+ }>;
82
118
  };
83
119
  export declare const crewpayPlugin: {
84
120
  name: string;
@@ -92,7 +128,13 @@ export declare const crewpayPlugin: {
92
128
  content?: {
93
129
  text?: string;
94
130
  };
95
- }) => Promise<ActionResult>;
131
+ }) => Promise<{
132
+ success: boolean;
133
+ data: unknown;
134
+ } | {
135
+ success: boolean;
136
+ error: string;
137
+ }>;
96
138
  }[];
97
139
  providers: never[];
98
140
  services: never[];
package/dist/index.js CHANGED
@@ -1,35 +1,34 @@
1
1
  /**
2
2
  * ElizaOS plugin scaffold for CrewPay.
3
- * Docs: https://docs.elizaos.ai/plugins/development
3
+ * Prefer MCP: npx -y crewpay-mcp@1.2.3 or https://mcp.crewpay.dev/mcp
4
4
  *
5
- * Env: CREWPAY_API_KEY (or CREW_AGENT_API_KEY), optional CREW_LAUNCHER_KEY (burner), CREW_API_URL.
6
- * Launch/wire require dryRunToken (from dry-run) + confirmPhrase APPROVE_SOL_SPEND + humanConfirmed.
5
+ * Launch requires dryRunId from CREW_LAUNCH_DRY_RUN after human approval
6
+ * on the approvalUrl page (no confirm phrase).
7
7
  */
8
- import { CrewPayClient, loadCrewPayEnv, SOL_SPEND_CONFIRM_PHRASE, } from './client.js';
8
+ import { CrewPayClient, loadCrewPayEnv } from './client.js';
9
9
  function client() {
10
10
  return new CrewPayClient(loadCrewPayEnv());
11
11
  }
12
- function ok(data, text) {
13
- return { success: true, text: text ?? JSON.stringify(data, null, 2), data };
14
- }
15
- function fail(err) {
16
- const message = err instanceof Error ? err.message : String(err);
17
- return { success: false, error: message, text: message };
18
- }
19
12
  function parseJsonContent(message) {
20
- const raw = message.content?.text?.trim() || '{}';
13
+ const text = message.content?.text?.trim() || '{}';
21
14
  try {
22
- const parsed = JSON.parse(raw);
15
+ const parsed = JSON.parse(text);
23
16
  return typeof parsed === 'object' && parsed ? parsed : {};
24
17
  }
25
18
  catch {
26
19
  return {};
27
20
  }
28
21
  }
22
+ function ok(data) {
23
+ return { success: true, data };
24
+ }
25
+ function fail(e) {
26
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
27
+ }
29
28
  export const crewDiscoverAction = {
30
29
  name: 'CREW_DISCOVER',
31
- similes: ['CREWPAY_DISCOVER', 'CREW_API_INFO'],
32
- description: 'GET CrewPay agent discovery JSON (endpoints, fee map, MCP).',
30
+ similes: ['CREWPAY_DISCOVER'],
31
+ description: 'Discover CrewPay agent API, fee map, and MCP surfaces.',
33
32
  validate: async () => true,
34
33
  handler: async () => {
35
34
  try {
@@ -42,8 +41,8 @@ export const crewDiscoverAction = {
42
41
  };
43
42
  export const crewAutohireAction = {
44
43
  name: 'CREW_AUTOHIRE',
45
- similes: ['CREWPAY_AUTOHIRE', 'HIRE_KOLS'],
46
- description: 'Preview KOL Autohire crew for a name/ticker/description (no SOL).',
44
+ similes: ['CREWPAY_AUTOHIRE'],
45
+ description: 'Preview Autohire KOL crew (no SOL).',
47
46
  validate: async () => Boolean(loadCrewPayEnv().apiKey),
48
47
  handler: async (_runtime, message) => {
49
48
  try {
@@ -57,7 +56,7 @@ export const crewAutohireAction = {
57
56
  export const crewDryRunAction = {
58
57
  name: 'CREW_LAUNCH_DRY_RUN',
59
58
  similes: ['CREWPAY_DRY_RUN', 'CREW_DRY_RUN'],
60
- description: `Dry-run a CrewPay launch (no mint, no SOL). Returns dryRunToken required for CREW_LAUNCH. Human must later supply confirmPhrase ${SOL_SPEND_CONFIRM_PHRASE}.`,
59
+ description: 'Dry-run a CrewPay launch (no mint, no SOL). Returns dryRunId + approvalUrl. Human must open approvalUrl before CREW_LAUNCH.',
61
60
  validate: async () => Boolean(loadCrewPayEnv().apiKey),
62
61
  handler: async (_runtime, message) => {
63
62
  try {
@@ -71,18 +70,17 @@ export const crewDryRunAction = {
71
70
  export const crewLaunchAction = {
72
71
  name: 'CREW_LAUNCH',
73
72
  similes: ['CREWPAY_LAUNCH'],
74
- description: `MAINNET launch after dry-run. Requires dryRunToken from CREW_LAUNCH_DRY_RUN, humanConfirmed:true, and confirmPhrase:${SOL_SPEND_CONFIRM_PHRASE} (human-supplied). Fee map 60/15/25; buyback not live.`,
73
+ description: 'MAINNET launch after dry-run. Requires dryRunId from CREW_LAUNCH_DRY_RUN after human approval on approvalUrl. Fee map 60/15/25; buyback not live.',
75
74
  validate: async () => Boolean(loadCrewPayEnv().apiKey && loadCrewPayEnv().launcherKey),
76
75
  handler: async (_runtime, message) => {
77
76
  try {
78
77
  const body = parseJsonContent(message);
79
- const humanConfirmed = body.humanConfirmed === true;
80
- const confirmPhrase = typeof body.confirmPhrase === 'string' ? body.confirmPhrase : '';
81
- const dryRunToken = typeof body.dryRunToken === 'string' ? body.dryRunToken : '';
78
+ const dryRunId = typeof body.dryRunId === 'string' ? body.dryRunId : '';
79
+ delete body.dryRunId;
82
80
  delete body.humanConfirmed;
83
81
  delete body.confirmPhrase;
84
82
  delete body.dryRunToken;
85
- return ok(await client().launch(body, { humanConfirmed, confirmPhrase, dryRunToken }));
83
+ return ok(await client().launch(body, { dryRunId }));
86
84
  }
87
85
  catch (e) {
88
86
  return fail(e);
@@ -92,16 +90,15 @@ export const crewLaunchAction = {
92
90
  export const crewWireFeesAction = {
93
91
  name: 'CREW_WIRE_FEES',
94
92
  similes: ['CREWPAY_WIRE_FEES'],
95
- description: `Wire / repair fee-shares (spends SOL). Requires humanConfirmed:true and confirmPhrase:${SOL_SPEND_CONFIRM_PHRASE}.`,
93
+ description: 'Wire / repair fee-shares (spends SOL). Requires dryRunId from dry-run intent=wire-fees after wallet approval.',
96
94
  validate: async () => Boolean(loadCrewPayEnv().apiKey && loadCrewPayEnv().launcherKey),
97
95
  handler: async (_runtime, message) => {
98
96
  try {
99
97
  const body = parseJsonContent(message);
100
- const humanConfirmed = body.humanConfirmed === true;
101
- const confirmPhrase = typeof body.confirmPhrase === 'string' ? body.confirmPhrase : '';
102
98
  const mint = String(body.mint || '');
103
99
  const mode = typeof body.mode === 'string' ? body.mode : undefined;
104
- return ok(await client().wireFees({ mint, mode }, { humanConfirmed, confirmPhrase }));
100
+ const dryRunId = typeof body.dryRunId === 'string' ? body.dryRunId : '';
101
+ return ok(await client().wireFees({ mint, mode }, { dryRunId }));
105
102
  }
106
103
  catch (e) {
107
104
  return fail(e);
@@ -139,7 +136,7 @@ export const crewProofAction = {
139
136
  };
140
137
  export const crewpayPlugin = {
141
138
  name: 'crewpay',
142
- description: 'CrewPay — Solana Pump.fun launches with KOL Autohire and on-chain fee-shares (60/15/25). Buyback not live yet. Dry-run token + APPROVE_SOL_SPEND before launch.',
139
+ description: 'CrewPay — Solana Pump.fun launches with KOL Autohire and on-chain fee-shares (60/15/25). Buyback not live yet. Dry-run → approvalUrl → launch with dryRunId.',
143
140
  actions: [
144
141
  crewDiscoverAction,
145
142
  crewAutohireAction,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elizaos-plugin-crewpay",
3
- "version": "0.1.0",
4
- "description": "ElizaOS plugin for CrewPay \u2014 Solana Pump.fun KOL Autohire + fee-shares (60/15/25). Buyback cron not live. Requires dryRunToken + APPROVE_SOL_SPEND before launch.",
3
+ "version": "0.2.0",
4
+ "description": "ElizaOS plugin for CrewPay — Solana Pump.fun KOL Autohire + fee-shares (60/15/25). Buyback cron not live. Dry-run returns dryRunId + approvalUrl before launch.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -17,8 +17,7 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "scripts": {
20
- "build": "tsc -p tsconfig.json",
21
- "prepublishOnly": "npm run build"
20
+ "build": "tsc -p tsconfig.json"
22
21
  },
23
22
  "keywords": [
24
23
  "elizaos",
@@ -50,5 +49,6 @@
50
49
  },
51
50
  "publishConfig": {
52
51
  "access": "public"
53
- }
52
+ },
53
+ "private": false
54
54
  }