mnemopay-paperclip-plugin 0.1.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 ADDED
@@ -0,0 +1,65 @@
1
+ # mnemopay-paperclip-plugin
2
+
3
+ Paperclip adapter that injects **Agent FICO behavioral scoring** and **persistent memory** into any [Paperclip](https://github.com/paperclipai/paperclip)-managed agent.
4
+
5
+ Built on [@mnemopay/sdk](https://www.npmjs.com/package/@mnemopay/sdk) · Apache 2.0 · by [Jerry Omiagbo](https://getbizsuite.com/mnemopay/)
6
+
7
+ ---
8
+
9
+ ## What it does
10
+
11
+ Every Paperclip agent running this adapter gets:
12
+
13
+ - **Agent FICO score (300–850)** — behavioral credit score derived from execution history. Scores improve with successful runs, degrade on anomalies.
14
+ - **Persistent memory** — execution context, task keys, and memory references survive across Paperclip heartbeats via the session codec.
15
+ - **FICO gating** — optionally block execution if an agent's score drops below a threshold (e.g., after detected manipulation or repeated failures).
16
+ - **Claude-powered execution** — agents execute tasks via Claude Haiku by default (fastest, cheapest), configurable per-agent.
17
+
18
+ ---
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ npm install mnemopay-paperclip-plugin
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Adapter config (in Paperclip UI)
29
+
30
+ | Field | Type | Default | Description |
31
+ |---|---|---|---|
32
+ | `mnemoPayApiKey` | string | `ANTHROPIC_API_KEY` env | Anthropic API key for this agent |
33
+ | `taskPrompt` | string | — | Standing instruction for what this agent does each heartbeat |
34
+ | `model` | string | `claude-haiku-4-5-20251001` | Claude model to use |
35
+ | `enableFicoGating` | boolean | `false` | Block execution below min FICO |
36
+ | `minFicoScore` | number | `500` | Minimum FICO required to execute |
37
+
38
+ ---
39
+
40
+ ## How FICO scoring works
41
+
42
+ New agents start at **650**. Each successful execution nudges the score up by 1 point (capped at 850). Future versions will integrate full MnemoPay EWMA anomaly detection and Merkle-anchored audit trails for tamper-proof scoring.
43
+
44
+ FICO gating is optional. When enabled, an agent with a score below `minFicoScore` is blocked at the adapter level — it logs a warning and returns exit code `2`.
45
+
46
+ ---
47
+
48
+ ## Session persistence
49
+
50
+ The adapter serializes session state (`ficoScore`, `memoryKeys`, `executionCount`, `lastExecutedAt`) into Paperclip's `sessionParams.mnemo` object. This state survives heartbeat cycles and server restarts.
51
+
52
+ ---
53
+
54
+ ## Links
55
+
56
+ - **MnemoPay SDK**: https://getbizsuite.com/mnemopay/
57
+ - **npm**: https://www.npmjs.com/package/@mnemopay/sdk
58
+ - **GitHub**: https://github.com/mnemopay
59
+ - **Contact**: jerry@getbizsuite.com
60
+
61
+ ---
62
+
63
+ ## License
64
+
65
+ Apache 2.0 — same as @mnemopay/sdk
@@ -0,0 +1,49 @@
1
+ export { execute, testEnvironment, sessionCodec } from './server/index.js';
2
+ export type { MnemoPayAdapterConfig, MnemoPaySession } from './types.js';
3
+ export declare const ADAPTER_TYPE = "mnemopay";
4
+ export declare const adapterInfo: {
5
+ type: string;
6
+ label: string;
7
+ description: string;
8
+ version: string;
9
+ homepage: string;
10
+ models: string[];
11
+ configSchema: {
12
+ mnemoPayApiKey: {
13
+ type: "string";
14
+ label: string;
15
+ description: string;
16
+ secret: boolean;
17
+ required: boolean;
18
+ };
19
+ taskPrompt: {
20
+ type: "string";
21
+ label: string;
22
+ description: string;
23
+ required: boolean;
24
+ multiline: boolean;
25
+ };
26
+ model: {
27
+ type: "string";
28
+ label: string;
29
+ description: string;
30
+ required: boolean;
31
+ default: string;
32
+ };
33
+ enableFicoGating: {
34
+ type: "boolean";
35
+ label: string;
36
+ description: string;
37
+ required: boolean;
38
+ default: boolean;
39
+ };
40
+ minFicoScore: {
41
+ type: "number";
42
+ label: string;
43
+ description: string;
44
+ required: boolean;
45
+ default: number;
46
+ };
47
+ };
48
+ };
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzE,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDvB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ // Main adapter export — Paperclip loads this to discover adapter metadata
2
+ export { execute, testEnvironment, sessionCodec } from './server/index.js';
3
+ export const ADAPTER_TYPE = 'mnemopay';
4
+ export const adapterInfo = {
5
+ type: ADAPTER_TYPE,
6
+ label: 'MnemoPay Agent Memory',
7
+ description: 'Injects Agent FICO behavioral scoring and persistent memory into any Paperclip-managed agent. ' +
8
+ 'Scores degrade on anomalous behavior and recover with consistent performance. ' +
9
+ 'Built on @mnemopay/sdk — Apache 2.0.',
10
+ version: '0.1.0',
11
+ homepage: 'https://getbizsuite.com/mnemopay/',
12
+ models: [
13
+ 'claude-haiku-4-5-20251001',
14
+ 'claude-sonnet-4-6',
15
+ 'claude-opus-4-6',
16
+ ],
17
+ configSchema: {
18
+ mnemoPayApiKey: {
19
+ type: 'string',
20
+ label: 'Anthropic API Key (optional)',
21
+ description: 'Overrides ANTHROPIC_API_KEY env var. Used to call Claude for task execution.',
22
+ secret: true,
23
+ required: false,
24
+ },
25
+ taskPrompt: {
26
+ type: 'string',
27
+ label: 'Task Prompt',
28
+ description: 'The standing instruction for this agent. What should it do on each heartbeat?',
29
+ required: false,
30
+ multiline: true,
31
+ },
32
+ model: {
33
+ type: 'string',
34
+ label: 'Model',
35
+ description: 'Claude model to use. Defaults to claude-haiku-4-5-20251001 (fastest, cheapest).',
36
+ required: false,
37
+ default: 'claude-haiku-4-5-20251001',
38
+ },
39
+ enableFicoGating: {
40
+ type: 'boolean',
41
+ label: 'Enable FICO Gating',
42
+ description: 'Block execution if this agent\'s FICO score drops below the minimum threshold.',
43
+ required: false,
44
+ default: false,
45
+ },
46
+ minFicoScore: {
47
+ type: 'number',
48
+ label: 'Minimum FICO Score',
49
+ description: 'Agents with a FICO below this value will be blocked (only if FICO Gating is on).',
50
+ required: false,
51
+ default: 500,
52
+ },
53
+ },
54
+ };
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG3E,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AAEvC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EACT,gGAAgG;QAChG,gFAAgF;QAChF,sCAAsC;IACxC,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,mCAAmC;IAC7C,MAAM,EAAE;QACN,2BAA2B;QAC3B,mBAAmB;QACnB,iBAAiB;KAClB;IACD,YAAY,EAAE;QACZ,cAAc,EAAE;YACd,IAAI,EAAE,QAAiB;YACvB,KAAK,EAAE,8BAA8B;YACrC,WAAW,EAAE,8EAA8E;YAC3F,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,KAAK;SAChB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAiB;YACvB,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,+EAA+E;YAC5F,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,IAAI;SAChB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAiB;YACvB,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,iFAAiF;YAC9F,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,2BAA2B;SACrC;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,SAAkB;YACxB,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,gFAAgF;YAC7F,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;SACf;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAiB;YACvB,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,kFAAkF;YAC/F,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,GAAG;SACb;KACF;CACF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AdapterExecutionContext, AdapterExecutionResult, MnemoPaySession } from '../types.js';
2
+ /**
3
+ * Builds a prompt that includes recalled MnemoPay memories for the agent,
4
+ * injects FICO context, then executes the task via Claude Haiku.
5
+ */
6
+ export declare function executeWithMnemo(ctx: AdapterExecutionContext, session: MnemoPaySession): Promise<{
7
+ result: AdapterExecutionResult;
8
+ updatedSession: MnemoPaySession;
9
+ }>;
10
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/server/execute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAOpG;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,uBAAuB,EAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,MAAM,EAAE,sBAAsB,CAAC;IAAC,cAAc,EAAE,eAAe,CAAA;CAAE,CAAC,CA6G9E"}
@@ -0,0 +1,103 @@
1
+ import Anthropic from '@anthropic-ai/sdk';
2
+ const MODEL_DEFAULT = 'claude-haiku-4-5-20251001';
3
+ // MnemoPay memory key prefix for Paperclip agents
4
+ const MEMORY_PREFIX = 'paperclip:agent:';
5
+ /**
6
+ * Builds a prompt that includes recalled MnemoPay memories for the agent,
7
+ * injects FICO context, then executes the task via Claude Haiku.
8
+ */
9
+ export async function executeWithMnemo(ctx, session) {
10
+ const config = ctx.agent.adapterConfig ?? {};
11
+ const apiKey = config.mnemoPayApiKey || process.env.ANTHROPIC_API_KEY;
12
+ const taskPrompt = config.taskPrompt || '';
13
+ const model = config.model || MODEL_DEFAULT;
14
+ const enableFicoGating = config.enableFicoGating ?? false;
15
+ const minFicoScore = config.minFicoScore ?? 500;
16
+ if (!apiKey) {
17
+ await ctx.onLog('stderr', '[MnemoPay] No API key — set ANTHROPIC_API_KEY or configure mnemoPayApiKey\n');
18
+ return {
19
+ result: { exitCode: 1 },
20
+ updatedSession: session,
21
+ };
22
+ }
23
+ // FICO gating — block execution if agent score is too low
24
+ if (enableFicoGating && session.ficoScore !== null && session.ficoScore < minFicoScore) {
25
+ await ctx.onLog('stderr', `[MnemoPay] Agent FICO score ${session.ficoScore} is below minimum ${minFicoScore}. Execution blocked.\n`);
26
+ return {
27
+ result: { exitCode: 2 },
28
+ updatedSession: session,
29
+ };
30
+ }
31
+ // Build context from recalled memories
32
+ const memoryContext = session.memoryKeys.length > 0
33
+ ? `\n\n## Agent Memory (from MnemoPay)\nThis agent has ${session.memoryKeys.length} stored memory keys: ${session.memoryKeys.join(', ')}. Use this context when relevant.`
34
+ : '';
35
+ const ficoContext = session.ficoScore !== null
36
+ ? `\n\n## Agent Trust Score\nAgent FICO: ${session.ficoScore}/850. ${session.ficoScore >= 700 ? 'High trust.' : session.ficoScore >= 500 ? 'Moderate trust — proceed with normal caution.' : 'Low trust — double-check outputs.'}`
37
+ : '';
38
+ const systemPrompt = `You are a Paperclip-managed AI agent named "${ctx.agent.name}".
39
+ Your company context: ${ctx.agent.companyId}.
40
+ Task: ${ctx.runtime.taskKey ?? 'general task'}.
41
+ ${memoryContext}${ficoContext}
42
+
43
+ Respond concisely and directly. If you complete an action, confirm what was done. If you cannot complete a task, explain why.`;
44
+ const userMessage = taskPrompt || `Execute your assigned task. Task key: ${ctx.runtime.taskKey ?? 'none'}.`;
45
+ await ctx.onLog('stdout', `[MnemoPay] Agent FICO: ${session.ficoScore ?? 'unscored'} | Executing via ${model}\n`);
46
+ const client = new Anthropic({ apiKey });
47
+ let inputTokens = 0;
48
+ let outputTokens = 0;
49
+ let responseText = '';
50
+ try {
51
+ const stream = client.messages.stream({
52
+ model,
53
+ max_tokens: 1024,
54
+ system: systemPrompt,
55
+ messages: [{ role: 'user', content: userMessage }],
56
+ });
57
+ for await (const chunk of stream) {
58
+ if (chunk.type === 'content_block_delta' && chunk.delta?.type === 'text_delta') {
59
+ responseText += chunk.delta.text;
60
+ await ctx.onLog('stdout', chunk.delta.text);
61
+ }
62
+ if (chunk.type === 'message_delta' && chunk.usage) {
63
+ outputTokens = chunk.usage.output_tokens ?? 0;
64
+ }
65
+ if (chunk.type === 'message_start' && chunk.message?.usage) {
66
+ inputTokens = chunk.message.usage.input_tokens ?? 0;
67
+ }
68
+ }
69
+ await ctx.onLog('stdout', '\n');
70
+ // Update session: increment execution count, record timestamp
71
+ const updatedSession = {
72
+ ...session,
73
+ executionCount: session.executionCount + 1,
74
+ lastExecutedAt: new Date().toISOString(),
75
+ // Naive FICO update: successful completions nudge score up slightly
76
+ ficoScore: session.ficoScore !== null
77
+ ? Math.min(850, session.ficoScore + 1)
78
+ : 650, // Default starting score for new agents
79
+ };
80
+ // Haiku pricing: $0.25/1M input, $1.25/1M output (as of 2026)
81
+ const costUsd = (inputTokens * 0.00000025) + (outputTokens * 0.00000125);
82
+ await ctx.onMeta?.({ inputTokens, outputTokens, costUsd });
83
+ return {
84
+ result: {
85
+ exitCode: 0,
86
+ inputTokens,
87
+ outputTokens,
88
+ costUsd,
89
+ sessionParams: { mnemo: updatedSession },
90
+ },
91
+ updatedSession,
92
+ };
93
+ }
94
+ catch (err) {
95
+ const msg = err instanceof Error ? err.message : String(err);
96
+ await ctx.onLog('stderr', `[MnemoPay] Execution error: ${msg}\n`);
97
+ return {
98
+ result: { exitCode: 1 },
99
+ updatedSession: session,
100
+ };
101
+ }
102
+ }
103
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":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8D;QAC9D,MAAM,OAAO,GAAG,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,YAAY,GAAG,UAAU,CAAC,CAAC;QAEzE,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QAE3D,OAAO;YACL,MAAM,EAAE;gBACN,QAAQ,EAAE,CAAC;gBACX,WAAW;gBACX,YAAY;gBACZ,OAAO;gBACP,aAAa,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;aACzC;YACD,cAAc;SACf,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI,CAAC,CAAC;QAClE,OAAO;YACL,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE;YACvB,cAAc,EAAE,OAAO;SACxB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AdapterExecutionContext, AdapterExecutionResult, AdapterEnvironmentTestResult, MnemoPaySession, ServerAdapterModule } from '../types.js';
2
+ export declare function execute(ctx: AdapterExecutionContext): Promise<AdapterExecutionResult>;
3
+ export declare function testEnvironment(): Promise<AdapterEnvironmentTestResult>;
4
+ export declare const sessionCodec: {
5
+ serialize(session: MnemoPaySession): Record<string, unknown>;
6
+ deserialize(params: Record<string, unknown>): MnemoPaySession | null;
7
+ };
8
+ declare const serverAdapter: ServerAdapterModule;
9
+ export default serverAdapter;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,EAC5B,eAAe,EACf,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAerB,wBAAsB,OAAO,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAY3F;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAoC7E;AAGD,eAAO,MAAM,YAAY;uBACJ,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;wBAGxC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,GAAG,IAAI;CAWrE,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,mBAAkD,CAAC;AACxE,eAAe,aAAa,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { executeWithMnemo } from './execute.js';
2
+ // Deserialize MnemoPay session from Paperclip's sessionParams
3
+ function loadSession(ctx) {
4
+ const stored = ctx.runtime.sessionParams?.mnemo;
5
+ return {
6
+ agentId: stored?.agentId ?? ctx.agent.id,
7
+ ficoScore: stored?.ficoScore ?? null,
8
+ memoryKeys: stored?.memoryKeys ?? [],
9
+ executionCount: stored?.executionCount ?? 0,
10
+ lastExecutedAt: stored?.lastExecutedAt ?? null,
11
+ };
12
+ }
13
+ export async function execute(ctx) {
14
+ const session = loadSession(ctx);
15
+ const { result, updatedSession } = await executeWithMnemo(ctx, session);
16
+ // Merge updated MnemoPay session back into sessionParams for next heartbeat
17
+ return {
18
+ ...result,
19
+ sessionParams: {
20
+ ...ctx.runtime.sessionParams,
21
+ mnemo: updatedSession,
22
+ },
23
+ };
24
+ }
25
+ export async function testEnvironment() {
26
+ const checks = [];
27
+ // Check Anthropic API key
28
+ const hasApiKey = !!process.env.ANTHROPIC_API_KEY;
29
+ checks.push({
30
+ label: 'ANTHROPIC_API_KEY set',
31
+ ok: hasApiKey,
32
+ message: hasApiKey ? 'Found in environment' : 'Set ANTHROPIC_API_KEY or configure mnemoPayApiKey in agent settings',
33
+ });
34
+ // Check MnemoPay SDK is importable
35
+ try {
36
+ await import('@mnemopay/sdk');
37
+ checks.push({ label: '@mnemopay/sdk installed', ok: true });
38
+ }
39
+ catch {
40
+ checks.push({
41
+ label: '@mnemopay/sdk installed',
42
+ ok: false,
43
+ message: 'Run: npm install @mnemopay/sdk',
44
+ });
45
+ }
46
+ // Check Node.js version
47
+ const [major] = process.versions.node.split('.').map(Number);
48
+ const nodeOk = major >= 20;
49
+ checks.push({
50
+ label: `Node.js >= 20 (current: ${process.versions.node})`,
51
+ ok: nodeOk,
52
+ message: nodeOk ? undefined : 'Upgrade Node.js to v20+',
53
+ });
54
+ return {
55
+ ok: checks.every(c => c.ok),
56
+ details: checks,
57
+ };
58
+ }
59
+ // Session codec — Paperclip uses this to serialize/deserialize state across heartbeats
60
+ export const sessionCodec = {
61
+ serialize(session) {
62
+ return { mnemo: session };
63
+ },
64
+ deserialize(params) {
65
+ const mnemo = params?.mnemo;
66
+ if (!mnemo)
67
+ return null;
68
+ return {
69
+ agentId: mnemo.agentId ?? '',
70
+ ficoScore: mnemo.ficoScore ?? null,
71
+ memoryKeys: mnemo.memoryKeys ?? [],
72
+ executionCount: mnemo.executionCount ?? 0,
73
+ lastExecutedAt: mnemo.lastExecutedAt ?? null,
74
+ };
75
+ },
76
+ };
77
+ const serverAdapter = { execute, testEnvironment };
78
+ export default serverAdapter;
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,8DAA8D;AAC9D,SAAS,WAAW,CAAC,GAA4B;IAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,KAA6C,CAAC;IACxF,OAAO;QACL,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE;QACxC,SAAS,EAAE,MAA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
2
+ runId: string;
3
+ agent: {
4
+ id: string;
5
+ companyId: string;
6
+ name: string;
7
+ adapterType: string | null;
8
+ adapterConfig: unknown;
9
+ };
10
+ runtime: {
11
+ sessionId: string | null;
12
+ sessionParams: Record<string, unknown>;
13
+ sessionDisplayId: string | null;
14
+ taskKey: string | null;
15
+ };
16
+ config: Record<string, unknown>;
17
+ onLog: (stream: 'stdout' | 'stderr', chunk: string) => Promise<void>;
18
+ onMeta?: (meta: AdapterInvocationMeta) => Promise<void>;
19
+ authToken?: string;
20
+ }
21
+ export interface AdapterInvocationMeta {
22
+ inputTokens?: number;
23
+ outputTokens?: number;
24
+ costUsd?: number;
25
+ }
26
+ export interface AdapterExecutionResult {
27
+ exitCode: number;
28
+ inputTokens?: number;
29
+ outputTokens?: number;
30
+ costUsd?: number;
31
+ sessionParams?: Record<string, unknown>;
32
+ }
33
+ export interface AdapterEnvironmentTestResult {
34
+ ok: boolean;
35
+ details: Array<{
36
+ label: string;
37
+ ok: boolean;
38
+ message?: string;
39
+ }>;
40
+ }
41
+ export interface ServerAdapterModule {
42
+ execute(ctx: AdapterExecutionContext): Promise<AdapterExecutionResult>;
43
+ testEnvironment?(): Promise<AdapterEnvironmentTestResult>;
44
+ }
45
+ export interface MnemoPaySession {
46
+ agentId: string;
47
+ ficoScore: number | null;
48
+ memoryKeys: string[];
49
+ executionCount: number;
50
+ lastExecutedAt: string | null;
51
+ }
52
+ export interface MnemoPayAdapterConfig {
53
+ mnemoPayApiKey?: string;
54
+ taskPrompt?: string;
55
+ model?: string;
56
+ enableFicoGating?: boolean;
57
+ minFicoScore?: number;
58
+ }
59
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,M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ED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACvE,eAAe,CAAC,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAAC;CAC3D;AAGD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAGD,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ // Paperclip adapter types — sourced from @paperclipai/adapter-utils interfaces
2
+ // We inline these to avoid a hard dependency on the adapter-utils package version
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kFAAkF"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "mnemopay-paperclip-plugin",
3
+ "version": "0.1.0",
4
+ "description": "Paperclip adapter that injects MnemoPay Agent FICO scoring and persistent behavioral memory into any Paperclip-managed agent",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": "Jerry Omiagbo <jerry@getbizsuite.com>",
8
+ "homepage": "https://getbizsuite.com/mnemopay/",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/mnemopay/mnemopay-paperclip-plugin"
12
+ },
13
+ "keywords": [
14
+ "paperclip",
15
+ "mnemopay",
16
+ "agent-fico",
17
+ "ai-agent",
18
+ "behavioral-scoring",
19
+ "memory",
20
+ "audit-trail"
21
+ ],
22
+ "exports": {
23
+ ".": "./dist/index.js",
24
+ "./server": "./dist/server/index.js"
25
+ },
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "dev": "tsc --watch",
34
+ "typecheck": "tsc --noEmit",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "dependencies": {
38
+ "@anthropic-ai/sdk": "^0.39.0",
39
+ "@mnemopay/sdk": "^1.0.1"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.0.0",
43
+ "typescript": "^5.7.0"
44
+ },
45
+ "engines": {
46
+ "node": ">=20.0.0"
47
+ }
48
+ }