@kanvas/openclaw-plugin 0.1.16 → 0.1.18

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.
@@ -0,0 +1,103 @@
1
+ export class DealsService {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async listDeals(first = 25, search, where) {
7
+ const query = `
8
+ query ListDeals($first: Int, $search: String, $where: QueryDealsWhereWhereConditions) {
9
+ deals(first: $first, search: $search, where: $where) {
10
+ data {
11
+ id
12
+ uuid
13
+ title
14
+ description
15
+ created_at
16
+ updated_at
17
+ owner { id uuid displayname }
18
+ lead { id uuid }
19
+ people { id uuid firstname lastname }
20
+ organization { id name }
21
+ pipeline { id name }
22
+ stage { id name }
23
+ status { id name }
24
+ }
25
+ paginatorInfo {
26
+ currentPage
27
+ lastPage
28
+ total
29
+ }
30
+ }
31
+ }
32
+ `;
33
+ return this.client.query(query, { first, search, where });
34
+ }
35
+ async getDeal(id) {
36
+ const query = `
37
+ query GetDeal($id: ID!) {
38
+ deal(id: $id) {
39
+ id
40
+ uuid
41
+ title
42
+ description
43
+ created_at
44
+ updated_at
45
+ owner { id uuid displayname }
46
+ lead { id uuid }
47
+ people { id uuid firstname lastname }
48
+ organization { id name }
49
+ pipeline { id name }
50
+ stage { id name }
51
+ status { id name }
52
+ tags { id name }
53
+ custom_fields { name value }
54
+ }
55
+ }
56
+ `;
57
+ return this.client.query(query, { id });
58
+ }
59
+ async createDeal(input) {
60
+ const mutation = `
61
+ mutation CreateDeal($input: DealInput!) {
62
+ createDeal(input: $input) {
63
+ id
64
+ uuid
65
+ title
66
+ description
67
+ created_at
68
+ owner { id uuid displayname }
69
+ pipeline { id name }
70
+ stage { id name }
71
+ status { id name }
72
+ }
73
+ }
74
+ `;
75
+ return this.client.query(mutation, { input });
76
+ }
77
+ async updateDeal(id, input) {
78
+ const mutation = `
79
+ mutation UpdateDeal($id: ID!, $input: UpdateDealInput!) {
80
+ updateDeal(id: $id, input: $input) {
81
+ id
82
+ uuid
83
+ title
84
+ description
85
+ updated_at
86
+ owner { id uuid displayname }
87
+ pipeline { id name }
88
+ stage { id name }
89
+ status { id name }
90
+ }
91
+ }
92
+ `;
93
+ return this.client.query(mutation, { id, input });
94
+ }
95
+ async deleteDeal(id) {
96
+ const mutation = `
97
+ mutation DeleteDeal($id: ID!) {
98
+ deleteDeal(id: $id)
99
+ }
100
+ `;
101
+ return this.client.query(mutation, { id });
102
+ }
103
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,157 @@
1
+ export class EventsService {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async listEvents(first = 25, search, where) {
7
+ const query = `
8
+ query ListEvents($first: Int, $search: String, $where: QueryEventsWhereWhereConditions) {
9
+ events(first: $first, search: $search, where: $where) {
10
+ data {
11
+ id
12
+ uuid
13
+ name
14
+ slug
15
+ description
16
+ created_at
17
+ updated_at
18
+ type { id name }
19
+ eventStatus { id name }
20
+ category { id name }
21
+ versions {
22
+ data {
23
+ id
24
+ start_at
25
+ end_at
26
+ dates {
27
+ id
28
+ date
29
+ start_time
30
+ end_time
31
+ }
32
+ }
33
+ }
34
+ }
35
+ paginatorInfo {
36
+ currentPage
37
+ lastPage
38
+ total
39
+ }
40
+ }
41
+ }
42
+ `;
43
+ return this.client.query(query, { first, search, where });
44
+ }
45
+ async getEvent(id) {
46
+ const query = `
47
+ query GetEvent($where: QueryEventsWhereWhereConditions) {
48
+ events(first: 1, where: $where) {
49
+ data {
50
+ id
51
+ uuid
52
+ name
53
+ slug
54
+ description
55
+ created_at
56
+ updated_at
57
+ type { id name }
58
+ eventStatus { id name }
59
+ category { id name }
60
+ resources_id
61
+ resources_type
62
+ versions {
63
+ data {
64
+ id
65
+ version
66
+ start_at
67
+ end_at
68
+ max_capacity
69
+ dates {
70
+ id
71
+ date
72
+ start_time
73
+ end_time
74
+ }
75
+ }
76
+ }
77
+ tags { id name }
78
+ custom_fields { name value }
79
+ }
80
+ }
81
+ }
82
+ `;
83
+ return this.client.query(query, {
84
+ where: { column: "ID", operator: "EQ", value: id },
85
+ });
86
+ }
87
+ async createEvent(input) {
88
+ const mutation = `
89
+ mutation CreateEvent($input: EventInput!) {
90
+ createEvent(input: $input) {
91
+ id
92
+ uuid
93
+ name
94
+ slug
95
+ description
96
+ created_at
97
+ type { id name }
98
+ eventStatus { id name }
99
+ versions {
100
+ data {
101
+ id
102
+ start_at
103
+ end_at
104
+ dates {
105
+ id
106
+ date
107
+ start_time
108
+ end_time
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ `;
115
+ return this.client.query(mutation, { input });
116
+ }
117
+ async updateEvent(id, input) {
118
+ const mutation = `
119
+ mutation UpdateEvent($id: ID!, $input: EventUpdateInput!) {
120
+ updateEvent(id: $id, input: $input) {
121
+ id
122
+ uuid
123
+ name
124
+ description
125
+ updated_at
126
+ type { id name }
127
+ eventStatus { id name }
128
+ }
129
+ }
130
+ `;
131
+ return this.client.query(mutation, { id, input });
132
+ }
133
+ async deleteEvent(id) {
134
+ const mutation = `
135
+ mutation DeleteEvent($id: ID!) {
136
+ deleteEvent(id: $id)
137
+ }
138
+ `;
139
+ return this.client.query(mutation, { id });
140
+ }
141
+ async followEvent(input) {
142
+ const mutation = `
143
+ mutation FollowEvent($input: FollowInput!) {
144
+ followEvent(input: $input)
145
+ }
146
+ `;
147
+ return this.client.query(mutation, { input });
148
+ }
149
+ async unFollowEvent(input) {
150
+ const mutation = `
151
+ mutation UnFollowEvent($input: FollowInput!) {
152
+ unFollowEvent(input: $input)
153
+ }
154
+ `;
155
+ return this.client.query(mutation, { input });
156
+ }
157
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,203 @@
1
+ const PLAN_DETAIL_FIELDS = `
2
+ id
3
+ uuid
4
+ title
5
+ description
6
+ plan_type
7
+ status
8
+ priority
9
+ deadline_at
10
+ completion_pct
11
+ requires_human_approval
12
+ approved_at
13
+ review_outcome
14
+ started_at
15
+ completed_at
16
+ error_message
17
+ input
18
+ output
19
+ confidence_score
20
+ entity_namespace
21
+ entity_id
22
+ created_at
23
+ updated_at
24
+ agent { id name }
25
+ user { id firstname lastname }
26
+ approver { id firstname lastname }
27
+ parent { id title status }
28
+ tasks { id sequence title description status blocked_reason result started_at completed_at }
29
+ files { id uuid name url }
30
+ tags { id name }
31
+ `;
32
+ const PLAN_LIST_FIELDS = `
33
+ id
34
+ uuid
35
+ title
36
+ description
37
+ plan_type
38
+ status
39
+ priority
40
+ deadline_at
41
+ completion_pct
42
+ requires_human_approval
43
+ entity_namespace
44
+ entity_id
45
+ created_at
46
+ agent { id name }
47
+ tasks { id sequence title status blocked_reason }
48
+ `;
49
+ const TASK_FIELDS = `
50
+ id
51
+ uuid
52
+ sequence
53
+ title
54
+ description
55
+ status
56
+ blocked_reason
57
+ result
58
+ started_at
59
+ completed_at
60
+ created_at
61
+ updated_at
62
+ `;
63
+ export class NervousSystemService {
64
+ client;
65
+ constructor(client) {
66
+ this.client = client;
67
+ }
68
+ // ── Read ───────────────────────────────────────────────────
69
+ async listMyPlans(opts) {
70
+ const { agent_id, statuses, first = 50 } = opts;
71
+ const where = statuses && statuses.length
72
+ ? {
73
+ AND: [
74
+ { column: "AGENT_ID", operator: "EQ", value: agent_id },
75
+ { column: "STATUS", operator: "IN", value: statuses },
76
+ ],
77
+ }
78
+ : { column: "AGENT_ID", operator: "EQ", value: agent_id };
79
+ const query = `
80
+ query MyPlans($first: Int!, $where: QueryNervousSystemPlansWhereWhereConditions) {
81
+ nervousSystemPlans(
82
+ first: $first
83
+ where: $where
84
+ orderBy: [{ column: PRIORITY, order: DESC }, { column: DEADLINE_AT, order: ASC }]
85
+ ) {
86
+ data { ${PLAN_LIST_FIELDS} }
87
+ paginatorInfo { currentPage lastPage total }
88
+ }
89
+ }
90
+ `;
91
+ return this.client.query(query, { first, where });
92
+ }
93
+ async listPlans(opts = {}) {
94
+ const { first = 25, where, orderBy } = opts;
95
+ const query = `
96
+ query ListPlans($first: Int!, $where: QueryNervousSystemPlansWhereWhereConditions, $orderBy: [QueryNervousSystemPlansOrderByOrderByClause!]) {
97
+ nervousSystemPlans(first: $first, where: $where, orderBy: $orderBy) {
98
+ data { ${PLAN_LIST_FIELDS} }
99
+ paginatorInfo { currentPage lastPage total }
100
+ }
101
+ }
102
+ `;
103
+ return this.client.query(query, { first, where, orderBy });
104
+ }
105
+ async getPlan(id) {
106
+ const query = `
107
+ query GetPlan($id: ID!) {
108
+ nervousSystemPlan(id: $id) {
109
+ ${PLAN_DETAIL_FIELDS}
110
+ }
111
+ }
112
+ `;
113
+ return this.client.query(query, { id });
114
+ }
115
+ async getAgentCapabilities(agentId, framework) {
116
+ const query = `
117
+ query AgentCapabilities($agent_id: ID!, $framework: String) {
118
+ nervousSystemAgentCapabilities(agent_id: $agent_id, framework: $framework) {
119
+ skills {
120
+ id name description skill_type version is_active
121
+ }
122
+ tools {
123
+ id name description tool_type requires_permission version is_active
124
+ }
125
+ }
126
+ }
127
+ `;
128
+ return this.client.query(query, { agent_id: agentId, framework });
129
+ }
130
+ // ── Plan mutations ─────────────────────────────────────────
131
+ async createPlan(input) {
132
+ const mutation = `
133
+ mutation CreatePlan($input: CreateNervousSystemPlanInput!) {
134
+ createNervousSystemPlan(input: $input) {
135
+ ${PLAN_DETAIL_FIELDS}
136
+ }
137
+ }
138
+ `;
139
+ return this.client.query(mutation, { input });
140
+ }
141
+ async updatePlan(id, input) {
142
+ const mutation = `
143
+ mutation UpdatePlan($id: ID!, $input: UpdateNervousSystemPlanInput!) {
144
+ updateNervousSystemPlan(id: $id, input: $input) {
145
+ ${PLAN_DETAIL_FIELDS}
146
+ }
147
+ }
148
+ `;
149
+ return this.client.query(mutation, { id, input });
150
+ }
151
+ async approvePlan(id, input) {
152
+ const mutation = `
153
+ mutation ApprovePlan($id: ID!, $input: ApproveNervousSystemPlanInput!) {
154
+ approveNervousSystemPlan(id: $id, input: $input) {
155
+ id
156
+ status
157
+ requires_human_approval
158
+ approved_at
159
+ review_outcome
160
+ approver { id firstname lastname }
161
+ }
162
+ }
163
+ `;
164
+ return this.client.query(mutation, { id, input });
165
+ }
166
+ async deletePlan(id) {
167
+ const mutation = `
168
+ mutation DeletePlan($id: ID!) {
169
+ deleteNervousSystemPlan(id: $id)
170
+ }
171
+ `;
172
+ return this.client.query(mutation, { id });
173
+ }
174
+ // ── Task mutations ─────────────────────────────────────────
175
+ async addTask(planId, input) {
176
+ const mutation = `
177
+ mutation AddTask($plan_id: ID!, $input: NervousSystemTaskInput!) {
178
+ addTaskToNervousSystemPlan(plan_id: $plan_id, input: $input) {
179
+ ${TASK_FIELDS}
180
+ }
181
+ }
182
+ `;
183
+ return this.client.query(mutation, { plan_id: planId, input });
184
+ }
185
+ async updateTaskStatus(id, input) {
186
+ const mutation = `
187
+ mutation UpdateTaskStatus($id: ID!, $input: UpdateNervousSystemTaskStatusInput!) {
188
+ updateNervousSystemTaskStatus(id: $id, input: $input) {
189
+ ${TASK_FIELDS}
190
+ }
191
+ }
192
+ `;
193
+ return this.client.query(mutation, { id, input });
194
+ }
195
+ async deleteTask(id) {
196
+ const mutation = `
197
+ mutation DeleteTask($id: ID!) {
198
+ deleteNervousSystemTask(id: $id)
199
+ }
200
+ `;
201
+ return this.client.query(mutation, { id });
202
+ }
203
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -3,6 +3,7 @@ export class OrdersService {
3
3
  constructor(client) {
4
4
  this.client = client;
5
5
  }
6
+ // ── Read ───────────────────────────────────────────────────
6
7
  async searchOrders(search, first = 10) {
7
8
  const query = `
8
9
  query SearchOrders($first: Int!, $search: String) {
@@ -54,4 +55,148 @@ export class OrdersService {
54
55
  where: { column: "ID", operator: "EQ", value: id },
55
56
  });
56
57
  }
58
+ // ── Lookups ────────────────────────────────────────────────
59
+ async listOrderStatuses(first = 50) {
60
+ const query = `
61
+ query ListOrderStatuses($first: Int) {
62
+ orderStatuses(first: $first) {
63
+ data {
64
+ id
65
+ name
66
+ slug
67
+ is_default
68
+ is_final
69
+ sequence
70
+ order_type_id
71
+ }
72
+ }
73
+ }
74
+ `;
75
+ return this.client.query(query, { first });
76
+ }
77
+ async listOrderTypes(first = 50) {
78
+ const query = `
79
+ query ListOrderTypes($first: Int) {
80
+ orderTypes(first: $first) {
81
+ data {
82
+ id
83
+ name
84
+ slug
85
+ title
86
+ total_statuses
87
+ }
88
+ }
89
+ }
90
+ `;
91
+ return this.client.query(query, { first });
92
+ }
93
+ async listRegions(first = 50) {
94
+ const query = `
95
+ query ListRegions($first: Int) {
96
+ regions(first: $first) {
97
+ data {
98
+ id
99
+ uuid
100
+ name
101
+ slug
102
+ currency
103
+ is_default
104
+ }
105
+ }
106
+ }
107
+ `;
108
+ return this.client.query(query, { first });
109
+ }
110
+ // ── Write ──────────────────────────────────────────────────
111
+ async createDraftOrder(input) {
112
+ const mutation = `
113
+ mutation CreateDraftOrder($input: DraftOrderInput!) {
114
+ createDraftOrder(input: $input) {
115
+ id
116
+ uuid
117
+ order_number
118
+ status
119
+ total_gross_amount
120
+ total_net_amount
121
+ created_at
122
+ }
123
+ }
124
+ `;
125
+ return this.client.query(mutation, { input });
126
+ }
127
+ async updateOrder(id, input) {
128
+ const mutation = `
129
+ mutation UpdateOrder($id: ID!, $input: UpdateOrderInput!) {
130
+ updateOrder(id: $id, input: $input) {
131
+ order {
132
+ id
133
+ uuid
134
+ order_number
135
+ status
136
+ fulfillment_status
137
+ payment_status
138
+ total_gross_amount
139
+ }
140
+ message
141
+ }
142
+ }
143
+ `;
144
+ return this.client.query(mutation, { id, input });
145
+ }
146
+ async updateDraftOrderStatus(orderId, status) {
147
+ const mutation = `
148
+ mutation UpdateDraftOrderStatus($order_id: ID!, $status: OrderStatusEnum!) {
149
+ updateDraftOrderStatus(order_id: $order_id, status: $status) {
150
+ id
151
+ uuid
152
+ order_number
153
+ status
154
+ }
155
+ }
156
+ `;
157
+ return this.client.query(mutation, { order_id: orderId, status });
158
+ }
159
+ async transitionOrderStatus(orderId, statusSlug, date) {
160
+ const mutation = `
161
+ mutation TransitionOrderStatus($input: TransitionOrderStatusInput!) {
162
+ transitionOrderStatus(input: $input) {
163
+ status
164
+ message
165
+ }
166
+ }
167
+ `;
168
+ return this.client.query(mutation, {
169
+ input: { order_id: orderId, status_slug: statusSlug, date },
170
+ });
171
+ }
172
+ async changeOrderCustomer(orderId, customerId) {
173
+ const mutation = `
174
+ mutation OrderChangeCustomer($order_id: ID!, $customer_id: ID!) {
175
+ orderChangeCustomer(order_id: $order_id, customer_id: $customer_id)
176
+ }
177
+ `;
178
+ return this.client.queryWithAppKey(mutation, {
179
+ order_id: orderId,
180
+ customer_id: customerId,
181
+ });
182
+ }
183
+ async deleteOrder(id) {
184
+ const mutation = `
185
+ mutation DeleteOrder($id: ID!) {
186
+ deleteOrder(id: $id)
187
+ }
188
+ `;
189
+ return this.client.query(mutation, { id });
190
+ }
191
+ async sendOrderEmail(orderId, template) {
192
+ const mutation = `
193
+ mutation SendOrderEmail($order_id: ID!, $template: String) {
194
+ sendOrderEmail(order_id: $order_id, template: $template)
195
+ }
196
+ `;
197
+ return this.client.queryWithAppKey(mutation, {
198
+ order_id: orderId,
199
+ template,
200
+ });
201
+ }
57
202
  }
@@ -0,0 +1 @@
1
+ export {};