wowok 1.5.54 → 1.6.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wowok",
3
- "version": "1.5.54",
3
+ "version": "1.6.59",
4
4
  "description": "Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -39,7 +39,9 @@
39
39
  "move",
40
40
  "treasury",
41
41
  "payment",
42
- "arbitration"
42
+ "arbitration",
43
+ "oracle",
44
+ "AI agent"
43
45
  ],
44
46
  "author": "wowok",
45
47
  "license": "Apache-2.0",
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Provide a JSON call interface for AI
3
+ *
4
+ */
5
+
6
+ import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
7
+ import { Protocol, } from '../protocol';
8
+ import { Bcs, IsValidAddress, IsValidArgType, IsValidU64, parseObjectType, IsValidU8 } from '../utils'
9
+ import { Errors, ERROR} from '../exception'
10
+ import { MultiGetObjectsParams } from '@mysten/sui/client';
11
+ import { Permission, PermissionIndex } from '../permission';
12
+ import { BCS } from '@mysten/bcs';
13
+ import { PermissionAnswerItem, PermissionIndexType } from '../permission';
14
+ import { Entity } from '../entity';
15
+ import { Repository_Policy_Mode } from '../repository';
16
+ export interface AgentFuncParameter {
17
+ type: 'string' | 'number' | 'boolean' | 'struct' ;
18
+ name: string;
19
+ description: string;
20
+ required: boolean;
21
+ }
22
+
23
+ export interface AgentFuncReturn {
24
+ type: 'string' | 'number' | 'boolean' | 'struct' ;
25
+ name: string;
26
+ description: string;
27
+ }
28
+ export interface AgentFunc {
29
+ name: string;
30
+ description: string;
31
+ module: string;
32
+ permissionIndex: number;
33
+ parameter: AgentFuncParameter[];
34
+ return?: AgentFuncReturn;
35
+ }
36
+
37
+ export const AGENT_FUNC: AgentFunc[] = [
38
+ {permissionIndex:PermissionIndex.repository, name:'Repository', description:'Launch new Repository', module: 'repository', parameter:[
39
+ {type:'string', name:'permission', description:'permission', required:true},
40
+ {type:'number', name:'mode', description:'mode', required:false},
41
+ ]},
42
+ {permissionIndex:PermissionIndex.repository_description, name:'Description', description:'Set Repository description', module: 'repository', parameter:[
43
+ {type:'string', name:'object', description:'object', required:true},
44
+ {type:'string', name:'description', description:'description', required:true},
45
+ ]},
46
+ {permissionIndex:PermissionIndex.repository_policy_mode, name:'Policy mode', description:'Set Repository policy mode', module: 'repository', parameter:[]},
47
+ {permissionIndex:PermissionIndex.repository_policies, name:'Policy', description:'Add/Remove/Edit Repository policy', module: 'repository', parameter:[]},
48
+ {permissionIndex:PermissionIndex.repository_policy_description, name:'Policy Description', description:'Set Repository policy description', module: 'repository', parameter:[]},
49
+ {permissionIndex:PermissionIndex.repository_policy_permission, name:'Policy Permission', description:'Set Repository policy permission', module: 'repository', parameter:[]},
50
+ {permissionIndex:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: 'repository', parameter:[]},
51
+
52
+ {permissionIndex:PermissionIndex.service, name:'Service', description:'Launch new Service', module: 'service', parameter:[]},
53
+ {permissionIndex:PermissionIndex.service_description, name:'Description', description:'Set Service description', module: 'service', parameter:[]},
54
+ {permissionIndex:PermissionIndex.service_price, name:'Price', description:'Set Service item price', module: 'service', parameter:[]},
55
+ {permissionIndex:PermissionIndex.service_stock, name:'Inventory', description:'Set Service item inventory', module: 'service', parameter:[]},
56
+ {permissionIndex:PermissionIndex.service_payee, name:'Payee', description:'Set Service payee', module: 'service', parameter:[]},
57
+ {permissionIndex:PermissionIndex.service_repository, name:'Repository', description:'Set Service repositories', module: 'service', parameter:[]},
58
+ {permissionIndex:PermissionIndex.service_withdraw_guards, name:'Withdraw Guard', description:'Set Service withdraw guards', module: 'service', parameter:[]},
59
+ {permissionIndex:PermissionIndex.service_refund_guards, name:'Refund Guard', description:'Set Service refund guards', module: 'service', parameter:[]},
60
+ {permissionIndex:PermissionIndex.service_add_sales, name:'Add sales', description:'Add sale items for Service', module: 'service', parameter:[]},
61
+ {permissionIndex:PermissionIndex.service_remove_sales, name:'Remove sales', description:'Remove sale items for Service', module: 'service', parameter:[]},
62
+ {permissionIndex:PermissionIndex.service_discount_transfer, name:'Discount', description:'Launch discounts for Service', module: 'service', parameter:[]},
63
+ {permissionIndex:PermissionIndex.service_withdraw, name:'Withdraw', description:'Widthraw from Service orders', module: 'service', parameter:[]},
64
+ {permissionIndex:PermissionIndex.service_buyer_guard, name:'Buyer Guard', description:'Set Guard of buying for Service', module: 'service', parameter:[]},
65
+ {permissionIndex:PermissionIndex.service_machine, name:'Machine', description:'Set Machine for Service', module: 'service', parameter:[]},
66
+ {permissionIndex:PermissionIndex.service_endpoint, name:'Endpoint', description:'Set Service endpoint', module: 'service', parameter:[]},
67
+ {permissionIndex:PermissionIndex.service_publish, name:'Publish', description:'Allowing the creation of Order', module: 'service', parameter:[]},
68
+ {permissionIndex:PermissionIndex.service_clone, name:'Clone', description:'Clone Service', module: 'service', parameter:[]},
69
+ {permissionIndex:PermissionIndex.service_customer_required, name:'Buyer info', description:'Set Service buyer info required', module: 'service', parameter:[]},
70
+ {permissionIndex:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service', parameter:[]},
71
+ {permissionIndex:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: 'service', parameter:[]},
72
+ {permissionIndex:PermissionIndex.service_arbitration, name:'Arbitration', description:'Add/Remove arbitration that allows refunds from orders at any time based on arbitration results', module: 'service', parameter:[]},
73
+
74
+ {permissionIndex:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: 'demand', parameter:[]},
75
+ {permissionIndex:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: 'demand', parameter:[]},
76
+ {permissionIndex:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'Expand Demand deadline', module: 'demand', parameter:[]},
77
+ {permissionIndex:PermissionIndex.demand_guard, name:'Guard', description:'Set Demand guard', module: 'demand', parameter:[]},
78
+ {permissionIndex:PermissionIndex.demand_description, name:'Description', description:'Set Demand description', module: 'demand', parameter:[]},
79
+ {permissionIndex:PermissionIndex.demand_yes, name:'Yes', description:'Pick the Deamand serice', module: 'demand', parameter:[]},
80
+
81
+ {permissionIndex:PermissionIndex.machine, name: 'Machine', description:'Launch new Machine', module: 'machine', parameter:[]},
82
+ {permissionIndex:PermissionIndex.machine_description, name: 'Description', description:'Set Machine description', module: 'machine', parameter:[]},
83
+ {permissionIndex:PermissionIndex.machine_repository, name: 'Repository', description:'Set Machine repository', module: 'machine', parameter:[]},
84
+ {permissionIndex:PermissionIndex.machine_clone, name: 'Clone', description:'Clone Machine', module: 'machine', parameter:[]},
85
+ {permissionIndex:PermissionIndex.machine_node, name: 'Node', description:'Set Machine nodes', module: 'machine', parameter:[]},
86
+ {permissionIndex:PermissionIndex.machine_endpoint, name: 'Endpoint', description:'Set Machine endpoint', module: 'machine', parameter:[]},
87
+ {permissionIndex:PermissionIndex.machine_pause, name: 'Pause', description:'Pause/Unpause Machine', module: 'machine', parameter:[]},
88
+ {permissionIndex:PermissionIndex.machine_publish, name: 'Publish', description:'Allowing the creation of Progress', module: 'machine', parameter:[]},
89
+
90
+ {permissionIndex:PermissionIndex.progress, name: 'Progress', description:'Launch new Progress', module: 'progress', parameter:[]},
91
+ {permissionIndex:PermissionIndex.progress_namedOperator, name: 'Operator', description:'Set Progress operators', module: 'progress', parameter:[]},
92
+ {permissionIndex:PermissionIndex.progress_bind_task, name: 'Bind', description:'Set Progress task', module: 'progress', parameter:[]},
93
+ {permissionIndex:PermissionIndex.progress_context_repository, name: 'Repository', description:'Set Progress repository', module: 'progress', parameter:[]},
94
+ {permissionIndex:PermissionIndex.progress_unhold, name: 'Unhold', description:'Release Progress holdings', module: 'progress', parameter:[]},
95
+ {permissionIndex:PermissionIndex.progress_parent, name: 'Parent', description:'Set Progress parent', module: 'progress', parameter:[]},
96
+
97
+ {permissionIndex:PermissionIndex.treasury, name: 'Treasury', description:'Launch new Treasury', module: 'treasury', parameter:[]},
98
+ {permissionIndex:PermissionIndex.treasury_deposit, name: 'Deposit', description:'Deposit coins', module: 'treasury', parameter:[]},
99
+ {permissionIndex:PermissionIndex.treasury_receive, name: 'Receive', description:'Receive coins from some address sent', module: 'treasury', parameter:[]},
100
+ {permissionIndex:PermissionIndex.treasury_withdraw, name: 'Withdraw', description:'Withdraw coins', module: 'treasury', parameter:[]},
101
+ {permissionIndex:PermissionIndex.treasury_withdraw_guard, name: 'Withdraw Guard', description:'Add/Remove Treasury withdraw guard', module: 'treasury', parameter:[]},
102
+ {permissionIndex:PermissionIndex.treasury_withdraw_mode, name: 'Withdraw mode', description:'Set Treasury withdraw mode', module: 'treasury', parameter:[]},
103
+ {permissionIndex:PermissionIndex.treasury_deposit_guard, name: 'Deposit Guard', description:'Set Treasury deposit guard', module: 'treasury', parameter:[]},
104
+ {permissionIndex:PermissionIndex.treasury_descritption, name: 'Description', description:'Set Treasury description', module: 'treasury', parameter:[]},
105
+
106
+ {permissionIndex:PermissionIndex.arbitration, name: 'Arbitration', description:'Launch new Arbitration', module: 'arbitration', parameter:[]},
107
+ {permissionIndex:PermissionIndex.arbitration_description, name: 'Description', description:'Set Arbitration description', module: 'arbitration', parameter:[]},
108
+ {permissionIndex:PermissionIndex.arbitration_endpoint, name: 'Endpoint', description:'Set Arbitration endpoint', module: 'arbitration', parameter:[]},
109
+ {permissionIndex:PermissionIndex.arbitration_fee, name: 'Fee', description:'Set Arbitration fee', module: 'arbitration', parameter:[]},
110
+ {permissionIndex:PermissionIndex.arbitration_guard, name: 'Guard', description:'Set Guard to apply for arbitration', module: 'arbitration', parameter:[]},
111
+ {permissionIndex:PermissionIndex.arbitration_arbitration, name: 'Arbitrate', description:'Determine the outcome of arbitration', module: 'arbitration', parameter:[]},
112
+ {permissionIndex:PermissionIndex.arbitration_pause, name: 'Pause', description:'Allowing/forbidding the creation of Arb', module: 'arbitration', parameter:[]},
113
+ {permissionIndex:PermissionIndex.arbitration_voting_guard, name: 'Voting Guard', description:'Add/Remove voting Guard', module: 'arbitration', parameter:[]},
114
+ {permissionIndex:PermissionIndex.arbitration_vote, name: 'Vote', description:'Vote on the application for arbitration', module: 'arbitration', parameter:[]},
115
+ {permissionIndex:PermissionIndex.arbitration_withdraw, name: 'Withdraw', description:'Withdraw the arbitration fee', module: 'arbitration', parameter:[]},
116
+ {permissionIndex:PermissionIndex.arbitration_treasury, name: 'Withdraw', description:'Set Treasury that fees was collected at the time of withdrawal', module: 'arbitration', parameter:[]},
117
+ ]
118
+ export class AgentCall {
119
+
120
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Provide a JSON query interface for AI
3
+ *
4
+ */
5
+
6
+ import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
7
+ import { Protocol, } from '../protocol';
8
+ import { Bcs, IsValidAddress } from '../utils'
9
+ import { Errors, ERROR} from '../exception'
10
+ import { Entity } from '../entity';
11
+
12
+
13
+ export interface EntityQuery {
14
+ address: string;
15
+ showTags?: boolean;
16
+ showMarks?: boolean;
17
+ }
18
+
19
+ export interface EntityDetail {
20
+ name: string;
21
+ description: string;
22
+ avatar: string;
23
+ x: string;
24
+ discord: string;
25
+ homepage: string;
26
+ }
27
+
28
+ export interface ObjectTag {
29
+ object: string;
30
+ nick_name: string;
31
+ tags: string[];
32
+ }
33
+
34
+ export interface ObjectMark {
35
+ mark_name: string;
36
+ objects: string[];
37
+ }
38
+
39
+ export interface EntityAnswer {
40
+ address: string;
41
+ like: number;
42
+ dislike: number;
43
+ details: EntityDetail;
44
+ resource_object?: string;
45
+ lastActive_digest?: string;
46
+ marks?: ObjectMark[];
47
+ tags?: ObjectTag[];
48
+ }
49
+
50
+ export class ENTITY_QUERY {
51
+ /*json: EntityQuery; return EntityAnswer */
52
+ static entity_json = async (json:string) : Promise<string> => {
53
+ try {
54
+ const q : EntityQuery = JSON.parse(json);
55
+ return JSON.stringify(await ENTITY_QUERY.entity(q));
56
+ } catch (e) {
57
+ return JSON.stringify({error:e});
58
+ }
59
+ }
60
+
61
+ static entity = async (query:EntityQuery) : Promise<EntityAnswer> => {
62
+ if (!IsValidAddress(query.address)) {
63
+ ERROR(Errors.IsValidAddress, 'entity.address')
64
+ }
65
+
66
+ const txb = new TransactionBlock();
67
+ Entity.From(txb).query_ent(query.address);
68
+
69
+ const res = await Protocol.Client().devInspectTransactionBlock({sender:query.address, transactionBlock:txb});
70
+ if (!res.results || res.results?.length !== 1 || res.results[0].returnValues?.length !== 1 ) {
71
+ ERROR(Errors.Fail, 'entity.fail')
72
+ }
73
+
74
+ const r1 = Bcs.getInstance().de_ent(Uint8Array.from(res!.results![0].returnValues![0][0]));
75
+ const a = Bcs.getInstance().de_entInfo(Uint8Array.from(r1.avatar));
76
+ var ret : EntityAnswer = {address:query.address, like:r1.like, dislike:r1.dislike, resource_object:r1.resource?.some ?? undefined,
77
+ details:{homepage:a.homepage, name:a.name, avatar:a.avatar, x:a.twitter, discord:a.discord, description:a.description},
78
+ };
79
+
80
+ if (r1.resource?.some && query.showTags) {
81
+ const res2 = await Protocol.Client().getObject({id:r1.resource?.some, options:{showContent:true, showPreviousTransaction:true, showType:true}});
82
+ ret.tags = (res2?.data?.content as any)?.fields?.tags?.map((v:any) => {
83
+ return {address:v.fields.object, nick:v.fields.nick, tags:v.fields.tags}
84
+ })
85
+
86
+ ret.lastActive_digest = res2.data?.previousTransaction ?? '';
87
+ }
88
+
89
+ if (r1.resource?.some && query.showMarks) {
90
+ const fields = await Protocol.Client().getDynamicFields({parentId:r1.resource?.some});
91
+ if (fields.data.length > 0) {
92
+ const objects = await Protocol.Client().multiGetObjects({ids:fields.data.map(v => v.objectId), options:{showContent:true}});
93
+ ret.marks = objects.map((i:any) => {
94
+ return {mark_name:i.data.content.fields.name, objects:i.data.content.fields.value}
95
+ })
96
+ }
97
+ }
98
+ return ret
99
+ }
100
+ }