@kanvas/openclaw-plugin 0.1.7 → 0.1.9
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/dist/domains/crm/index.js +52 -4
- package/dist/index.js +1 -1
- package/dist/tools/crm.js +40 -0
- package/package.json +1 -1
|
@@ -369,12 +369,13 @@ export class CrmService {
|
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
371
|
async addLeadMessageByLeadId(input) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
// The channel_slug for lead notes must be the lead's UUID
|
|
373
|
+
const leadUuid = await this.getLeadUuid(String(input.leadId));
|
|
374
|
+
if (!leadUuid) {
|
|
375
|
+
throw new Error(`Lead ${input.leadId} not found`);
|
|
375
376
|
}
|
|
376
377
|
const created = await this.addLeadMessage({
|
|
377
|
-
channel_slug:
|
|
378
|
+
channel_slug: leadUuid,
|
|
378
379
|
message: input.message,
|
|
379
380
|
parent_id: input.parent_id,
|
|
380
381
|
is_public: input.is_public,
|
|
@@ -442,6 +443,21 @@ export class CrmService {
|
|
|
442
443
|
`;
|
|
443
444
|
return this.client.query(query, { first, page, channelSlug });
|
|
444
445
|
}
|
|
446
|
+
async getLeadUuid(leadId) {
|
|
447
|
+
const response = await this.client.query(`
|
|
448
|
+
query LeadUuid($first: Int!, $where: QueryLeadsWhereWhereConditions) {
|
|
449
|
+
leads(first: $first, where: $where) {
|
|
450
|
+
data {
|
|
451
|
+
uuid
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
`, {
|
|
456
|
+
first: 1,
|
|
457
|
+
where: { column: "ID", operator: "EQ", value: leadId },
|
|
458
|
+
});
|
|
459
|
+
return response.data?.leads?.data?.[0]?.uuid ?? null;
|
|
460
|
+
}
|
|
445
461
|
async getLeadPrimaryChannelSlug(leadId) {
|
|
446
462
|
const response = await this.client.query(`
|
|
447
463
|
query LeadChannels($first: Int!, $where: QueryLeadsWhereWhereConditions) {
|
|
@@ -811,6 +827,38 @@ export class CrmService {
|
|
|
811
827
|
`;
|
|
812
828
|
return this.client.query(query, { first });
|
|
813
829
|
}
|
|
830
|
+
async createPeopleRelationship(input) {
|
|
831
|
+
const mutation = `
|
|
832
|
+
mutation CreatePeopleRelationship($input: PeopleRelationshipInput!) {
|
|
833
|
+
createPeopleRelationship(input: $input) {
|
|
834
|
+
id
|
|
835
|
+
name
|
|
836
|
+
description
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
`;
|
|
840
|
+
return this.client.query(mutation, { input });
|
|
841
|
+
}
|
|
842
|
+
async updatePeopleRelationship(id, input) {
|
|
843
|
+
const mutation = `
|
|
844
|
+
mutation UpdatePeopleRelationship($id: ID!, $input: UpdatePeopleRelationshipInput!) {
|
|
845
|
+
updatePeopleRelationship(id: $id, input: $input) {
|
|
846
|
+
id
|
|
847
|
+
name
|
|
848
|
+
description
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
`;
|
|
852
|
+
return this.client.query(mutation, { id, input });
|
|
853
|
+
}
|
|
854
|
+
async deletePeopleRelationship(id) {
|
|
855
|
+
const mutation = `
|
|
856
|
+
mutation DeletePeopleRelationship($id: ID!) {
|
|
857
|
+
deletePeopleRelationship(id: $id)
|
|
858
|
+
}
|
|
859
|
+
`;
|
|
860
|
+
return this.client.query(mutation, { id });
|
|
861
|
+
}
|
|
814
862
|
async listContactTypes(first = 50) {
|
|
815
863
|
const query = `
|
|
816
864
|
query ContactTypes($first: Int) {
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,7 @@ export default {
|
|
|
103
103
|
await runSetup();
|
|
104
104
|
});
|
|
105
105
|
}, { commands: ["setup"] });
|
|
106
|
-
api.logger.info("Kanvas plugin registered —
|
|
106
|
+
api.logger.info("Kanvas plugin registered — 53 tools loaded");
|
|
107
107
|
},
|
|
108
108
|
};
|
|
109
109
|
const KANVAS_SYSTEM_CONTEXT = `
|
package/dist/tools/crm.js
CHANGED
|
@@ -447,6 +447,46 @@ export function registerCrmTools(api, service, ensureAuth) {
|
|
|
447
447
|
return toolResult(await service.listPeopleRelationships(params.first));
|
|
448
448
|
},
|
|
449
449
|
});
|
|
450
|
+
api.registerTool({
|
|
451
|
+
name: "kanvas_create_people_relationship",
|
|
452
|
+
label: "Create People Relationship",
|
|
453
|
+
description: "Create a new relationship type (e.g. Architect, Client, Consultant) for use when adding participants to leads.",
|
|
454
|
+
parameters: Type.Object({
|
|
455
|
+
name: Type.String({ description: 'Relationship name (e.g. "Architect", "Consultant", "Decision Maker")' }),
|
|
456
|
+
description: Type.Optional(Type.String({ description: "Description of this relationship type" })),
|
|
457
|
+
}),
|
|
458
|
+
async execute(_id, params) {
|
|
459
|
+
await ensureAuth();
|
|
460
|
+
return toolResult(await service.createPeopleRelationship(params));
|
|
461
|
+
},
|
|
462
|
+
});
|
|
463
|
+
api.registerTool({
|
|
464
|
+
name: "kanvas_update_people_relationship",
|
|
465
|
+
label: "Update People Relationship",
|
|
466
|
+
description: "Update a relationship type's name or description.",
|
|
467
|
+
parameters: Type.Object({
|
|
468
|
+
id: Type.String({ description: "Relationship ID" }),
|
|
469
|
+
name: Type.Optional(Type.String()),
|
|
470
|
+
description: Type.Optional(Type.String()),
|
|
471
|
+
}),
|
|
472
|
+
async execute(_id, params) {
|
|
473
|
+
await ensureAuth();
|
|
474
|
+
const { id, ...input } = params;
|
|
475
|
+
return toolResult(await service.updatePeopleRelationship(id, input));
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
api.registerTool({
|
|
479
|
+
name: "kanvas_delete_people_relationship",
|
|
480
|
+
label: "Delete People Relationship",
|
|
481
|
+
description: "Delete a relationship type.",
|
|
482
|
+
parameters: Type.Object({
|
|
483
|
+
id: Type.String({ description: "Relationship ID" }),
|
|
484
|
+
}),
|
|
485
|
+
async execute(_id, params) {
|
|
486
|
+
await ensureAuth();
|
|
487
|
+
return toolResult(await service.deletePeopleRelationship(params.id));
|
|
488
|
+
},
|
|
489
|
+
});
|
|
450
490
|
api.registerTool({
|
|
451
491
|
name: "kanvas_list_contact_types",
|
|
452
492
|
label: "List Contact Types",
|
package/package.json
CHANGED