@gholl-studio/pier-connector 0.3.16 → 0.3.17

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/inbound.ts +16 -16
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gholl-studio/pier-connector",
3
3
  "author": "gholl",
4
- "version": "0.3.16",
4
+ "version": "0.3.17",
5
5
  "description": "OpenClaw plugin that connects to the Pier job marketplace. Automatically fetches, executes, and reports distributed tasks for rewards.",
6
6
  "type": "module",
7
7
  "main": "src/index.ts",
package/src/inbound.ts CHANGED
@@ -24,19 +24,19 @@ export async function handleInbound(
24
24
  const agentIds = Array.isArray(agentsList) ? agentsList.map((a: any) => a.id) : Object.keys(agentsList);
25
25
  logger.info(`[pier-connector][${robot.accountId}] Available agents in OpenClaw: ${JSON.stringify(agentIds)}`);
26
26
 
27
- // 1. Resolve Account-Scoped Configuration (Standard Nested Structure)
27
+ // 1. Resolve Account-Scoped Configuration (Flat Structure for SDK)
28
+ /**
29
+ * ★ Multi-Account Configuration Isolation:
30
+ * SDK helpers like resolveAgentRoute expect the channel config at the top level
31
+ * of cfg.channels.<channelName>. Replacing it with the robot's merged config
32
+ * ensures the SDK sees the correct agentId/dmPolicy for this specific account.
33
+ */
28
34
  const rootConfig = api.config || {};
29
35
  const accountScopedCfg = {
30
36
  ...rootConfig,
31
37
  channels: {
32
38
  ...rootConfig.channels,
33
- pier: {
34
- ...(rootConfig.channels?.pier || {}),
35
- accounts: {
36
- ...(rootConfig.channels?.pier?.accounts || {}),
37
- [robot.accountId]: robot.config
38
- }
39
- }
39
+ pier: robot.config
40
40
  }
41
41
  };
42
42
 
@@ -44,18 +44,18 @@ export async function handleInbound(
44
44
  const route = api.runtime.channel.routing.resolveAgentRoute({
45
45
  cfg: accountScopedCfg,
46
46
  channel: 'pier',
47
- accountId: inbound.accountId,
47
+ accountId: robot.accountId,
48
48
  peer: { kind: 'direct', id: jobId }
49
49
  });
50
50
 
51
51
  const finalAgentId = route.agentId || 'main';
52
52
  const routingSource = route.agentId ? 'sdk-scoped-route' : 'sdk-default-fallback';
53
53
 
54
- logger.info(`[pier-connector] Routing account '${inbound.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
54
+ logger.info(`[pier-connector] Routing account '${robot.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
55
55
 
56
- // Debug: Check Agent Identity
56
+ // Debug: Check Agent Identity (Correct Signature: resolveAgentIdentity(cfg, agentId))
57
57
  try {
58
- const identity = (api.runtime as any).agent.resolveAgentIdentity(finalAgentId);
58
+ const identity = (api.runtime as any).agent.resolveAgentIdentity(accountScopedCfg, finalAgentId);
59
59
  logger.info(`[pier-connector:debug] Identity resolution for ${finalAgentId}: ${JSON.stringify(identity)}`);
60
60
  } catch (err: any) {
61
61
  logger.warn(`[pier-connector:debug] Identity resolution failed for ${finalAgentId}: ${err.message}`);
@@ -95,13 +95,13 @@ export async function handleInbound(
95
95
  Body: inbound.body,
96
96
  BodyForAgent: inbound.body,
97
97
  RawBody: inbound.body,
98
- From: inbound.senderId,
98
+ From: `pier:${inbound.senderId}`,
99
99
  To: `chat:${jobId}`,
100
100
  SessionKey: dynamicSessionKey,
101
- AccountId: inbound.accountId,
101
+ AccountId: robot.accountId,
102
102
  ChatType: 'direct',
103
103
  SenderId: inbound.senderId,
104
- SenderName: robot.accountId,
104
+ SenderName: inbound.senderId, // Use senderId as name if unknown
105
105
  Provider: 'pier',
106
106
  Surface: 'pier',
107
107
  OriginatingChannel: 'pier',
@@ -124,7 +124,7 @@ export async function handleInbound(
124
124
  const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
125
125
  deliver: async (payload: any, info: any) => {
126
126
  const currentMeta = robot.activeNodeJobs.get(jobId);
127
- const respondingAgent = payload.agentId || payload.btw?.agentId || payload.channelData?.agentId || 'unknown';
127
+ const respondingAgent = payload.agentId || payload.btw?.agentId || payload.channelData?.agentId || finalAgentId;
128
128
 
129
129
  logger.info(`[pier-connector:trace] Outbound delivery triggered for job ${jobId}. Type: ${info?.kind}. Responding Agent: ${respondingAgent}.`);
130
130
  logger.info(`[pier-connector:debug] FULL PAYLOAD: ${JSON.stringify(payload)}`);