@agrentingai/paperclip-adapter 0.2.2 → 0.4.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.
@@ -1,5 +1,21 @@
1
+ import * as _paperclipai_adapter_utils from '@paperclipai/adapter-utils';
2
+ import { AdapterExecutionContext, AdapterExecutionResult, AdapterEnvironmentTestContext, AdapterEnvironmentTestResult, AdapterConfigSchema, AdapterSessionCodec } from '@paperclipai/adapter-utils';
1
3
  import { IncomingHttpHeaders } from 'http';
2
4
 
5
+ declare const type = "agrenting";
6
+ declare const label = "Agrenting";
7
+ declare const agentConfigurationDoc = "# agrenting agent configuration\n\nAdapter: agrenting\n\nUse when:\n- A Paperclip agent should delegate each heartbeat to a remote agent hired from Agrenting.\n- The operator has an Agrenting user API token and sufficient ledger balance.\n\nCore fields:\n- agrentingUrl (required): Agrenting base URL, normally https://agrenting.com\n- apiKey (required, secret): Agrenting user API token (ap_...)\n- agentDid (required): DID of the marketplace agent to hire\n- capabilityRequested (optional): defaults to the first capability on the agent profile\n- price (optional): defaults to the agent's current base price\n- timeoutSec (optional): maximum time to poll a hiring, default 600\n- pollIntervalMs (optional): hiring status poll interval, default 2000\n- deliveryMode (optional): output by default; push requires repository access\n- repoUrl (optional): repository URL used only when deliveryMode is push\n\nRecommended API-key scopes:\n- agents:discover, agents:read, hire:create, hirings:read, hirings:cancel\n- add balance:read and artifacts:read when sharing the key with Apps/Claude\n- deposits:create and account:read/account:write are optional elevated scopes\n- set max_price_per_hire on the key to cap paid actions\n\nExecution:\n- Each Paperclip run creates one canonical Agrenting hiring.\n- The Paperclip run id is sent as client_idempotency_key so safe retries deduplicate.\n- Paperclip polls the hiring until it completes, fails, is cancelled, or times out.\n- Push delivery can use a repository URL from Paperclip and an Agrenting-stored\n GitHub token. The adapter never stores a repository token in agent config.\n";
8
+ /** Canonical Paperclip ServerAdapterModule execution entry point. */
9
+ declare function executePaperclip(ctx: AdapterExecutionContext): Promise<AdapterExecutionResult>;
10
+ /** Canonical structured environment test used by Paperclip. */
11
+ declare function testPaperclipEnvironment(ctx: AdapterEnvironmentTestContext): Promise<AdapterEnvironmentTestResult>;
12
+ declare function getPaperclipConfigSchema(): AdapterConfigSchema;
13
+ type CompatibilitySessionCodec = AdapterSessionCodec & {
14
+ encode(state: unknown): string;
15
+ decode(blob: string | null | undefined): unknown;
16
+ };
17
+ declare const paperclipSessionCodec: CompatibilitySessionCodec;
18
+
3
19
  /**
4
20
  * Agrenting adapter configuration schema.
5
21
  * These fields are rendered in the Paperclip UI when configuring an Agrenting agent.
@@ -19,6 +35,16 @@ interface AgrentingAdapterConfig {
19
35
  pricingModel?: "fixed" | "per-token" | "subscription";
20
36
  /** Task timeout in seconds (default: 600) */
21
37
  timeoutSec?: number;
38
+ /** Default capability used by the canonical Paperclip hiring adapter. */
39
+ capabilityRequested?: string;
40
+ /** Price offered for each hiring. Defaults to the selected agent's base price. */
41
+ price?: string;
42
+ /** Poll interval for the hiring lifecycle in milliseconds (default: 2000). */
43
+ pollIntervalMs?: number;
44
+ /** Agrenting delivery mode for canonical Paperclip runs. */
45
+ deliveryMode?: "output" | "push";
46
+ /** Repository URL used for push delivery. */
47
+ repoUrl?: string;
22
48
  /** How instructions are handled: "managed" (uploaded to Agrenting) or "inline" (passed in task context) */
23
49
  instructionsBundleMode?: "managed" | "inline";
24
50
  }
@@ -113,7 +139,7 @@ interface AgentProfile {
113
139
  name: string;
114
140
  description?: string;
115
141
  capabilities: string[];
116
- pricing_tiers: Array<{
142
+ pricing_tiers?: Array<{
117
143
  model: string;
118
144
  price_per_task?: string;
119
145
  price_per_token?: string;
@@ -125,39 +151,87 @@ interface AgentProfile {
125
151
  average_rating: number;
126
152
  total_reviews: number;
127
153
  };
128
- reputation_score?: number;
154
+ reputation_score?: number | string;
129
155
  total_earnings?: string;
130
156
  verified?: boolean;
131
157
  response_time_avg?: number;
132
- availability_status: "available" | "busy" | "offline";
158
+ availability_status?: "available" | "busy" | "offline";
159
+ availability?: string;
160
+ status?: string;
133
161
  success_rate?: number;
134
162
  total_tasks_completed?: number;
135
163
  metadata?: Record<string, unknown>;
136
164
  avatar_url?: string;
137
- created_at: string;
165
+ created_at?: string;
138
166
  }
139
167
  /** Result of hiring an agent via POST /api/v1/agents/:did/hire */
140
168
  interface HireAgentResult {
141
- agent_did: string;
142
- adapter_config: {
143
- agrentingUrl: string;
169
+ hiring: Hiring;
170
+ config: {
144
171
  agentDid: string;
145
172
  pricingModel: string;
146
- webhookSecret?: string;
173
+ basePrice: string;
174
+ capabilities: string[];
175
+ hiringId: string;
176
+ metadata?: Record<string, unknown>;
147
177
  };
148
- status: "hired" | "pending_approval";
149
- hired_at: string;
150
178
  }
151
- /** Hiring record returned by POST /api/v1/agents/:did/hire */
179
+ /** Canonical payload required by POST /api/v1/agents/:did/hire. */
180
+ interface HireAgentOptions {
181
+ taskDescription: string;
182
+ capabilityRequested: string;
183
+ price: string | number;
184
+ repoUrl?: string;
185
+ repoAccessToken?: string;
186
+ deliveryMode?: "output" | "push";
187
+ clientIdempotencyKey?: string;
188
+ taskInput?: Record<string, unknown>;
189
+ clientMessage?: string;
190
+ }
191
+ type HiringStatus = "pending_payment" | "paid" | "queued" | "in_progress" | "completed" | "failed" | "cancelled" | "disputed" | "refunded" | (string & {});
192
+ /** Hiring record returned by the canonical Agrenting hiring REST API. */
152
193
  interface Hiring {
153
194
  id: string;
154
- agent_id: string;
155
- agent_did: string;
156
- client_agent_id: string;
157
- status: string;
195
+ status: HiringStatus;
196
+ final?: boolean;
197
+ agent_id?: string;
198
+ agent_did?: string;
199
+ client_agent_id?: string;
200
+ agent?: {
201
+ id: string;
202
+ did: string;
203
+ name: string;
204
+ category?: string;
205
+ capabilities?: string[];
206
+ base_price?: string;
207
+ reputation_score?: string;
208
+ status?: string;
209
+ } | null;
210
+ price?: string | null;
211
+ capability_requested?: string;
212
+ task_description?: string;
213
+ delivery_mode?: "output" | "push" | string;
158
214
  pricing_model?: string;
159
- created_at: string;
160
- updated_at: string;
215
+ task_input?: Record<string, unknown>;
216
+ task_output?: Record<string, unknown> | string | null;
217
+ failed_reason?: string | null;
218
+ repo_url?: string | null;
219
+ messages?: HiringMessage[];
220
+ artifacts?: Array<Record<string, unknown>>;
221
+ started_at?: string | null;
222
+ completed_at?: string | null;
223
+ failed_at?: string | null;
224
+ deadline_at?: string | null;
225
+ created_at?: string;
226
+ updated_at?: string;
227
+ }
228
+ /** Paginated response returned by GET /api/v1/hirings. */
229
+ interface HiringListResult {
230
+ hirings: Hiring[];
231
+ total: number;
232
+ page: number;
233
+ per_page: number;
234
+ total_pages: number;
161
235
  }
162
236
  /** Options for sending a message to a task */
163
237
  interface SendMessageOptions {
@@ -193,10 +267,12 @@ interface ReassignTaskResult {
193
267
  /** Hiring message for communication with hired agent */
194
268
  interface HiringMessage {
195
269
  id: string;
196
- hiring_id: string;
197
- sender_agent_id: string;
270
+ hiring_id?: string;
271
+ sender_agent_id?: string;
272
+ sender_type?: string;
198
273
  content: string;
199
- created_at: string;
274
+ created_at?: string;
275
+ inserted_at?: string;
200
276
  sender_name?: string;
201
277
  }
202
278
  /** Capability returned by GET /api/v1/capabilities */
@@ -210,6 +286,7 @@ interface Capability {
210
286
  /** Options for auto-selecting an agent */
211
287
  interface AutoSelectOptions {
212
288
  capability: string;
289
+ taskDescription: string;
213
290
  maxPrice?: string;
214
291
  minReputation?: number;
215
292
  sortBy?: "reputation_score" | "base_price" | "availability";
@@ -349,7 +426,7 @@ declare function cancelTask(config: AgrentingAdapterConfig, taskId: string): Pro
349
426
  * Hire an agent by DID. Returns hiring record and adapter config for auto-provisioning.
350
427
  * This is the primary entry point for the "browse marketplace, click Hire" flow.
351
428
  */
352
- declare function hireAgent(config: AgrentingAdapterConfig, agentDid: string): Promise<HireAgentResult>;
429
+ declare function hireAgent(config: AgrentingAdapterConfig, agentDid: string, options: HireAgentOptions): Promise<HireAgentResult>;
353
430
  /**
354
431
  * Get full agent profile by DID.
355
432
  * Returns description, capabilities, pricing, reputation, and availability.
@@ -400,6 +477,8 @@ declare function listHirings(config: AgrentingAdapterConfig, options?: {
400
477
  limit?: number;
401
478
  offset?: number;
402
479
  }): Promise<Hiring[]>;
480
+ /** Cancel an active hiring and release its escrow according to Agrenting policy. */
481
+ declare function cancelHiring(config: AgrentingAdapterConfig, hiringId: string): Promise<Hiring>;
403
482
  /**
404
483
  * Auto-select mode: given a capability requirement, discover the best agent,
405
484
  * hire them, and return the adapter config for immediate use.
@@ -438,15 +517,76 @@ declare function forwardCommentToAgrenting$1(config: AgrentingAdapterConfig, tas
438
517
  * Called by the webhook handler when it receives task messages.
439
518
  */
440
519
  declare function processIncomingMessage$1(message: TaskMessage): string;
520
+ /** Paperclip skill shape (subset of the canonical Paperclip Skill). */
521
+ interface PaperclipSkill {
522
+ id: string;
523
+ name: string;
524
+ description?: string;
525
+ }
526
+ /**
527
+ * Detect a sensible default model/provider for the configured Agrenting agent.
528
+ * Paperclip calls this to pre-populate the adapter UI when an agent is
529
+ * created. Returns null if no info is available.
530
+ */
531
+ declare function detectModel(config: Pick<AgrentingAdapterConfig, "agrentingUrl" | "apiKey" | "agentDid">): Promise<{
532
+ provider: string;
533
+ model: string;
534
+ } | null>;
535
+ /**
536
+ * Enumerate the configured Agrenting agent's capabilities and map them to
537
+ * Paperclip's Skill shape.
538
+ */
539
+ declare function listSkills(config: AgrentingAdapterConfig): Promise<PaperclipSkill[]>;
540
+ /**
541
+ * Reconcile the agent's current capabilities against Paperclip's local skill
542
+ * registry. Returns sets to add and remove.
543
+ */
544
+ declare function syncSkills(config: AgrentingAdapterConfig, existing: PaperclipSkill[]): Promise<{
545
+ added: PaperclipSkill[];
546
+ removed: PaperclipSkill[];
547
+ }>;
548
+ /**
549
+ * Session codec — Paperclip uses this to serialise session state across
550
+ * heartbeats. Hirings carry no rich session state, so we pass JSON through.
551
+ */
552
+ declare const sessionCodec: _paperclipai_adapter_utils.AdapterSessionCodec & {
553
+ encode(state: unknown): string;
554
+ decode(blob: string | null | undefined): unknown;
555
+ };
556
+ /**
557
+ * Legacy `AgentAdapter.invoke`. Forwards to {@link execute}.
558
+ */
559
+ declare function invoke(config: AgrentingAdapterConfig, params: {
560
+ input: string;
561
+ capability: string;
562
+ instructions?: string;
563
+ maxPrice?: string;
564
+ paymentType?: string;
565
+ }): Promise<AgrentingExecutionResult>;
566
+ /**
567
+ * Legacy `AgentAdapter.status`. Returns the current run status.
568
+ */
569
+ declare function status(config: AgrentingAdapterConfig, taskId: string): Promise<{
570
+ status: AgrentingTaskStatus;
571
+ progressPercent: number;
572
+ progressMessage?: string;
573
+ }>;
574
+ /**
575
+ * Legacy `AgentAdapter.cancel`. Cancels a running task; throws on failure
576
+ * so Paperclip can treat the call as a void Promise.
577
+ */
578
+ declare function cancel(config: AgrentingAdapterConfig, taskId: string): Promise<void>;
441
579
  /**
442
580
  * Create the server-side adapter module.
443
- * This is the entry point for Paperclip's server adapter registry.
581
+ * Paperclip plugin loaders call this factory from the package root. The
582
+ * current ServerAdapterModule members are combined with explicitly named
583
+ * compatibility helpers for pre-0.4 consumers.
444
584
  */
445
585
  declare function createServerAdapter(): {
446
586
  name: "agrenting";
447
- execute: typeof execute;
448
- testEnvironment: typeof testEnvironment;
449
- getConfigSchema: typeof getConfigSchema;
587
+ legacyExecute: typeof execute;
588
+ legacyTestEnvironment: typeof testEnvironment;
589
+ getLegacyConfigSchema: typeof getConfigSchema;
450
590
  startWebhookListener: typeof startWebhookListener;
451
591
  stopWebhookListener: typeof stopWebhookListener;
452
592
  registerWebhook: typeof registerWebhook;
@@ -464,6 +604,7 @@ declare function createServerAdapter(): {
464
604
  sendMessageToHiring: typeof sendMessageToHiring;
465
605
  getHiringMessages: typeof getHiringMessages;
466
606
  retryHiring: typeof retryHiring;
607
+ cancelHiring: typeof cancelHiring;
467
608
  getHiring: typeof getHiring;
468
609
  listHirings: typeof listHirings;
469
610
  autoSelectAgent: typeof autoSelectAgent;
@@ -474,6 +615,21 @@ declare function createServerAdapter(): {
474
615
  getTransactions: typeof getTransactions;
475
616
  deposit: typeof deposit;
476
617
  withdraw: typeof withdraw;
618
+ invoke: typeof invoke;
619
+ status: typeof status;
620
+ cancel: typeof cancel;
621
+ legacyDetectModel: typeof detectModel;
622
+ legacyListSkills: typeof listSkills;
623
+ legacySyncSkills: typeof syncSkills;
624
+ type: string;
625
+ execute: typeof executePaperclip;
626
+ testEnvironment: typeof testPaperclipEnvironment;
627
+ sessionCodec: _paperclipai_adapter_utils.AdapterSessionCodec & {
628
+ encode(state: unknown): string;
629
+ decode(blob: string | null | undefined): unknown;
630
+ };
631
+ getConfigSchema: typeof getPaperclipConfigSchema;
632
+ agentConfigurationDoc: string;
477
633
  };
478
634
 
479
635
  /**
@@ -631,12 +787,10 @@ declare class AgrentingClient {
631
787
  * Returns capabilities, pricing tiers, reviews, and availability.
632
788
  */
633
789
  getAgentProfile(agentDid: string): Promise<AgentProfile>;
634
- /** Hire/bind an agent to your account.
635
- * Returns adapter config so Paperclip can auto-provision the agent.
790
+ /** Create a paid hiring for an agent.
791
+ * Agrenting requires a concrete task, capability, and offered price.
636
792
  */
637
- hireAgent(agentDid: string, options?: {
638
- pricingModel?: string;
639
- }): Promise<HireAgentResult>;
793
+ hireAgent(agentDid: string, options: HireAgentOptions): Promise<HireAgentResult>;
640
794
  /** Send a message to a running task (mid-task instructions, feedback, or questions).
641
795
  * Enables bidirectional communication between the Paperclip user and the remote agent.
642
796
  */
@@ -658,7 +812,7 @@ declare class AgrentingClient {
658
812
  */
659
813
  sendMessageToHiring(hiringId: string, content: string): Promise<HiringMessage>;
660
814
  /** Get messages for a hiring.
661
- * GET /api/v1/hirings/:id/messages
815
+ * The canonical API includes recent messages in GET /api/v1/hirings/:id.
662
816
  */
663
817
  getHiringMessages(hiringId: string): Promise<HiringMessage[]>;
664
818
  /** Retry a failed hiring.
@@ -669,6 +823,10 @@ declare class AgrentingClient {
669
823
  * GET /api/v1/hirings/:id
670
824
  */
671
825
  getHiring(hiringId: string): Promise<Hiring>;
826
+ /** Cancel an active hiring.
827
+ * POST /api/v1/hirings/:id/cancel
828
+ */
829
+ cancelHiring(hiringId: string): Promise<Hiring>;
672
830
  /** List hirings for the authenticated agent.
673
831
  * GET /api/v1/hirings
674
832
  */
@@ -892,4 +1050,31 @@ declare function formatInsufficientBalanceComment(balanceInfo: BalanceInfo): str
892
1050
  */
893
1051
  declare function verifyWebhookSignature(rawBody: string, signature: string, secret: string): Promise<boolean>;
894
1052
 
895
- export { type AgentInfo, type AgentProfile, type AgrentingAdapterConfig, AgrentingClient, type AgrentingExecutionResult, type AgrentingTask, type AgrentingTaskStatus, type AgrentingWebhookPayload, type AutoSelectOptions, type BalanceCheckOptions, type BalanceInfo, type Capability, type CreateTaskPaymentOptions, type DiscoverAgentsOptions, type HireAgentResult, type Hiring, type HiringMessage, MAX_POLLS, POLL_INTERVALS_MS, type PaperclipApiClient, type PaymentInfo, type PollOptions, type PollResult, type ReassignTaskResult, type RetryHiringOptions, type SendMessageOptions, type SendMessageResult, type TaskMessage, type TransactionInfo, type WebhookHandlerOptions, autoSelectAgent, canSubmitTask, checkBalance, createServerAdapter, createWebhookHandler, deregisterWebhook, executeWithRetry, formatAgentResponse, formatInsufficientBalanceComment, formatLowBalanceComment, forwardCommentToAgrenting, getActiveTaskMappings, getAgentProfile, getBackoffMs, getHiring, getHiringMessages, getTaskMessages, getWebhookGracePeriodMs, hireAgent, listCapabilities, listHirings, pollTaskUntilDone, processIncomingMessage, reassignTask, registerTaskMapping, registerWebhook, retryHiring, sendMessageToHiring, sendMessageToTask, unregisterTaskMapping, verifyWebhookSignature };
1053
+ declare const agrentingAppGalleryEntry: {
1054
+ key: string;
1055
+ name: string;
1056
+ logoUrl: string;
1057
+ tagline: string;
1058
+ description: string;
1059
+ authKind: "api_key";
1060
+ transportTemplate: {
1061
+ transport: "remote_http";
1062
+ url: string;
1063
+ };
1064
+ credentialFields: {
1065
+ label: string;
1066
+ configPath: string;
1067
+ helpUrl: string;
1068
+ required: true;
1069
+ placement: "header";
1070
+ key: string;
1071
+ prefix: string;
1072
+ }[];
1073
+ recommendedDefaults: {
1074
+ access: string;
1075
+ askFirstRiskLevels: string[];
1076
+ };
1077
+ urlPatterns: string[];
1078
+ };
1079
+
1080
+ export { type AgentInfo, type AgentProfile, type AgrentingAdapterConfig, AgrentingClient, type AgrentingExecutionResult, type AgrentingTask, type AgrentingTaskStatus, type AgrentingWebhookPayload, type AutoSelectOptions, type BalanceCheckOptions, type BalanceInfo, type Capability, type CreateTaskPaymentOptions, type DiscoverAgentsOptions, type HireAgentOptions, type HireAgentResult, type Hiring, type HiringListResult, type HiringMessage, type HiringStatus, MAX_POLLS, POLL_INTERVALS_MS, type PaperclipApiClient, type PaperclipSkill, type PaymentInfo, type PollOptions, type PollResult, type ReassignTaskResult, type RetryHiringOptions, type SendMessageOptions, type SendMessageResult, type TaskMessage, type TransactionInfo, type WebhookHandlerOptions, agentConfigurationDoc, agrentingAppGalleryEntry, autoSelectAgent, canSubmitTask, cancel, cancelHiring, cancelTask, checkBalance, createServerAdapter, createWebhookHandler, deregisterWebhook, detectModel, execute, executePaperclip, executeWithRetry, formatAgentResponse, formatInsufficientBalanceComment, formatLowBalanceComment, forwardCommentToAgrenting, getActiveTaskMappings, getAgentProfile, getBackoffMs, getConfigSchema, getHiring, getHiringMessages, getPaperclipConfigSchema, getTaskMessages, getTaskProgress, getWebhookGracePeriodMs, hireAgent, invoke, label, listCapabilities, listHirings, listSkills, paperclipSessionCodec, pollTaskUntilDone, processIncomingMessage, reassignTask, registerTaskMapping, registerWebhook, retryHiring, sendMessageToHiring, sendMessageToTask, sessionCodec, status, syncSkills, testEnvironment, testPaperclipEnvironment, type, unregisterTaskMapping, verifyWebhookSignature };