@agrentingai/paperclip-adapter 0.3.0 → 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.
@@ -470,12 +549,12 @@ declare function syncSkills(config: AgrentingAdapterConfig, existing: PaperclipS
470
549
  * Session codec — Paperclip uses this to serialise session state across
471
550
  * heartbeats. Hirings carry no rich session state, so we pass JSON through.
472
551
  */
473
- declare const sessionCodec: {
552
+ declare const sessionCodec: _paperclipai_adapter_utils.AdapterSessionCodec & {
474
553
  encode(state: unknown): string;
475
554
  decode(blob: string | null | undefined): unknown;
476
555
  };
477
556
  /**
478
- * Canonical `AgentAdapter.invoke`. Forwards to {@link execute}.
557
+ * Legacy `AgentAdapter.invoke`. Forwards to {@link execute}.
479
558
  */
480
559
  declare function invoke(config: AgrentingAdapterConfig, params: {
481
560
  input: string;
@@ -485,7 +564,7 @@ declare function invoke(config: AgrentingAdapterConfig, params: {
485
564
  paymentType?: string;
486
565
  }): Promise<AgrentingExecutionResult>;
487
566
  /**
488
- * Canonical `AgentAdapter.status`. Returns the current run status.
567
+ * Legacy `AgentAdapter.status`. Returns the current run status.
489
568
  */
490
569
  declare function status(config: AgrentingAdapterConfig, taskId: string): Promise<{
491
570
  status: AgrentingTaskStatus;
@@ -493,21 +572,21 @@ declare function status(config: AgrentingAdapterConfig, taskId: string): Promise
493
572
  progressMessage?: string;
494
573
  }>;
495
574
  /**
496
- * Canonical `AgentAdapter.cancel`. Cancels a running task; throws on failure
575
+ * Legacy `AgentAdapter.cancel`. Cancels a running task; throws on failure
497
576
  * so Paperclip can treat the call as a void Promise.
498
577
  */
499
578
  declare function cancel(config: AgrentingAdapterConfig, taskId: string): Promise<void>;
500
579
  /**
501
580
  * Create the server-side adapter module.
502
- * Backward-compat convenience for callers that prefer a single bundle. New
503
- * Paperclip plugin loaders should use the named exports directly via
504
- * `~/.paperclip/adapter-plugins.json`.
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.
505
584
  */
506
585
  declare function createServerAdapter(): {
507
586
  name: "agrenting";
508
- execute: typeof execute;
509
- testEnvironment: typeof testEnvironment;
510
- getConfigSchema: typeof getConfigSchema;
587
+ legacyExecute: typeof execute;
588
+ legacyTestEnvironment: typeof testEnvironment;
589
+ getLegacyConfigSchema: typeof getConfigSchema;
511
590
  startWebhookListener: typeof startWebhookListener;
512
591
  stopWebhookListener: typeof stopWebhookListener;
513
592
  registerWebhook: typeof registerWebhook;
@@ -525,6 +604,7 @@ declare function createServerAdapter(): {
525
604
  sendMessageToHiring: typeof sendMessageToHiring;
526
605
  getHiringMessages: typeof getHiringMessages;
527
606
  retryHiring: typeof retryHiring;
607
+ cancelHiring: typeof cancelHiring;
528
608
  getHiring: typeof getHiring;
529
609
  listHirings: typeof listHirings;
530
610
  autoSelectAgent: typeof autoSelectAgent;
@@ -538,13 +618,18 @@ declare function createServerAdapter(): {
538
618
  invoke: typeof invoke;
539
619
  status: typeof status;
540
620
  cancel: typeof cancel;
541
- detectModel: typeof detectModel;
542
- listSkills: typeof listSkills;
543
- syncSkills: typeof syncSkills;
544
- sessionCodec: {
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 & {
545
628
  encode(state: unknown): string;
546
629
  decode(blob: string | null | undefined): unknown;
547
630
  };
631
+ getConfigSchema: typeof getPaperclipConfigSchema;
632
+ agentConfigurationDoc: string;
548
633
  };
549
634
 
550
635
  /**
@@ -702,12 +787,10 @@ declare class AgrentingClient {
702
787
  * Returns capabilities, pricing tiers, reviews, and availability.
703
788
  */
704
789
  getAgentProfile(agentDid: string): Promise<AgentProfile>;
705
- /** Hire/bind an agent to your account.
706
- * 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.
707
792
  */
708
- hireAgent(agentDid: string, options?: {
709
- pricingModel?: string;
710
- }): Promise<HireAgentResult>;
793
+ hireAgent(agentDid: string, options: HireAgentOptions): Promise<HireAgentResult>;
711
794
  /** Send a message to a running task (mid-task instructions, feedback, or questions).
712
795
  * Enables bidirectional communication between the Paperclip user and the remote agent.
713
796
  */
@@ -729,7 +812,7 @@ declare class AgrentingClient {
729
812
  */
730
813
  sendMessageToHiring(hiringId: string, content: string): Promise<HiringMessage>;
731
814
  /** Get messages for a hiring.
732
- * GET /api/v1/hirings/:id/messages
815
+ * The canonical API includes recent messages in GET /api/v1/hirings/:id.
733
816
  */
734
817
  getHiringMessages(hiringId: string): Promise<HiringMessage[]>;
735
818
  /** Retry a failed hiring.
@@ -740,6 +823,10 @@ declare class AgrentingClient {
740
823
  * GET /api/v1/hirings/:id
741
824
  */
742
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>;
743
830
  /** List hirings for the authenticated agent.
744
831
  * GET /api/v1/hirings
745
832
  */
@@ -963,4 +1050,31 @@ declare function formatInsufficientBalanceComment(balanceInfo: BalanceInfo): str
963
1050
  */
964
1051
  declare function verifyWebhookSignature(rawBody: string, signature: string, secret: string): Promise<boolean>;
965
1052
 
966
- 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 PaperclipSkill, type PaymentInfo, type PollOptions, type PollResult, type ReassignTaskResult, type RetryHiringOptions, type SendMessageOptions, type SendMessageResult, type TaskMessage, type TransactionInfo, type WebhookHandlerOptions, autoSelectAgent, canSubmitTask, cancel, cancelTask, checkBalance, createServerAdapter, createWebhookHandler, deregisterWebhook, detectModel, execute, executeWithRetry, formatAgentResponse, formatInsufficientBalanceComment, formatLowBalanceComment, forwardCommentToAgrenting, getActiveTaskMappings, getAgentProfile, getBackoffMs, getConfigSchema, getHiring, getHiringMessages, getTaskMessages, getTaskProgress, getWebhookGracePeriodMs, hireAgent, invoke, listCapabilities, listHirings, listSkills, pollTaskUntilDone, processIncomingMessage, reassignTask, registerTaskMapping, registerWebhook, retryHiring, sendMessageToHiring, sendMessageToTask, sessionCodec, status, syncSkills, testEnvironment, 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 };