wowok 1.5.56 → 1.6.60
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 +3 -2
- package/src/agent_call/call.ts +125 -0
- package/src/agent_query/events.ts +100 -0
- package/src/agent_query/objects.ts +608 -0
- package/src/agent_query/permission.ts +60 -0
- package/src/index.ts +4 -0
- package/src/machine.ts +20 -17
- package/src/permission.ts +9 -51
- package/src/progress.ts +20 -20
- package/src/protocol.ts +14 -17
- package/src/repository.ts +12 -11
- package/src/service.ts +5 -5
- package/src/treasury.ts +7 -7
- package/src/utils.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wowok",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.60",
|
|
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",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"treasury",
|
|
41
41
|
"payment",
|
|
42
42
|
"arbitration",
|
|
43
|
-
"oracle"
|
|
43
|
+
"oracle",
|
|
44
|
+
"AI agent"
|
|
44
45
|
],
|
|
45
46
|
"author": "wowok",
|
|
46
47
|
"license": "Apache-2.0",
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provide a call interface for AI
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
|
|
7
|
+
import { DemandObject, PermissionObject, Protocol, ServiceObject, } 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
|
+
import { LargeNumberLike } from 'crypto';
|
|
17
|
+
|
|
18
|
+
export type FUNC_TYPE = string | number | boolean | 'DemandObject' | 'PermissionObject';
|
|
19
|
+
export interface AgentFuncParameter {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
required: boolean;
|
|
23
|
+
type: FUNC_TYPE;
|
|
24
|
+
value?: FUNC_TYPE;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AgentFuncReturn {
|
|
28
|
+
type: DemandObject ;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface AgentFunc {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
module?: string;
|
|
37
|
+
permissionIndex: number;
|
|
38
|
+
parameter: AgentFuncParameter[];
|
|
39
|
+
return?: AgentFuncReturn;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const AGENT_FUNC: AgentFunc[] = [
|
|
43
|
+
{permissionIndex:PermissionIndex.repository, name:'Repository', description:'Launch new Repository', module: 'repository', parameter:[
|
|
44
|
+
{type: 'PermissionObject' , name:'permission', description:'Permission address or object', required:true},
|
|
45
|
+
{type: '"Relax mode" or "Strict mode"', name:'mode', description:'Relax mode: Allows entry of data other than policy. Used for informal, non-consensus situations.\nStrict mode: Prohibits entry of data beyond policy. Used in formal, fully consensus contexts.', required:false},
|
|
46
|
+
]},
|
|
47
|
+
{permissionIndex:PermissionIndex.repository_description, name:'Description', description:'Set Repository description', module: 'repository', parameter:[
|
|
48
|
+
{type:'DemandObject', name:'demand', description:'Demand address or object', required:true},
|
|
49
|
+
{type:'string', name:'description', description:'Demand description', required:true},
|
|
50
|
+
]},
|
|
51
|
+
{permissionIndex:PermissionIndex.repository_policy_mode, name:'Policy mode', description:'Set Repository policy mode', module: 'repository', parameter:[]},
|
|
52
|
+
{permissionIndex:PermissionIndex.repository_policies, name:'Policy', description:'Add/Remove/Edit Repository policy', module: 'repository', parameter:[]},
|
|
53
|
+
{permissionIndex:PermissionIndex.repository_policy_description, name:'Policy Description', description:'Set Repository policy description', module: 'repository', parameter:[]},
|
|
54
|
+
{permissionIndex:PermissionIndex.repository_policy_permission, name:'Policy Permission', description:'Set Repository policy permission', module: 'repository', parameter:[]},
|
|
55
|
+
{permissionIndex:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: 'repository', parameter:[]},
|
|
56
|
+
|
|
57
|
+
{permissionIndex:PermissionIndex.service, name:'Service', description:'Launch new Service', module: 'service', parameter:[]},
|
|
58
|
+
{permissionIndex:PermissionIndex.service_description, name:'Description', description:'Set Service description', module: 'service', parameter:[]},
|
|
59
|
+
{permissionIndex:PermissionIndex.service_price, name:'Price', description:'Set Service item price', module: 'service', parameter:[]},
|
|
60
|
+
{permissionIndex:PermissionIndex.service_stock, name:'Inventory', description:'Set Service item inventory', module: 'service', parameter:[]},
|
|
61
|
+
{permissionIndex:PermissionIndex.service_payee, name:'Payee', description:'Set Service payee', module: 'service', parameter:[]},
|
|
62
|
+
{permissionIndex:PermissionIndex.service_repository, name:'Repository', description:'Set Service repositories', module: 'service', parameter:[]},
|
|
63
|
+
{permissionIndex:PermissionIndex.service_withdraw_guards, name:'Withdraw Guard', description:'Set Service withdraw guards', module: 'service', parameter:[]},
|
|
64
|
+
{permissionIndex:PermissionIndex.service_refund_guards, name:'Refund Guard', description:'Set Service refund guards', module: 'service', parameter:[]},
|
|
65
|
+
{permissionIndex:PermissionIndex.service_add_sales, name:'Add sales', description:'Add sale items for Service', module: 'service', parameter:[]},
|
|
66
|
+
{permissionIndex:PermissionIndex.service_remove_sales, name:'Remove sales', description:'Remove sale items for Service', module: 'service', parameter:[]},
|
|
67
|
+
{permissionIndex:PermissionIndex.service_discount_transfer, name:'Discount', description:'Launch discounts for Service', module: 'service', parameter:[]},
|
|
68
|
+
{permissionIndex:PermissionIndex.service_withdraw, name:'Withdraw', description:'Widthraw from Service orders', module: 'service', parameter:[]},
|
|
69
|
+
{permissionIndex:PermissionIndex.service_buyer_guard, name:'Buyer Guard', description:'Set Guard of buying for Service', module: 'service', parameter:[]},
|
|
70
|
+
{permissionIndex:PermissionIndex.service_machine, name:'Machine', description:'Set Machine for Service', module: 'service', parameter:[]},
|
|
71
|
+
{permissionIndex:PermissionIndex.service_endpoint, name:'Endpoint', description:'Set Service endpoint', module: 'service', parameter:[]},
|
|
72
|
+
{permissionIndex:PermissionIndex.service_publish, name:'Publish', description:'Allowing the creation of Order', module: 'service', parameter:[]},
|
|
73
|
+
{permissionIndex:PermissionIndex.service_clone, name:'Clone', description:'Clone Service', module: 'service', parameter:[]},
|
|
74
|
+
{permissionIndex:PermissionIndex.service_customer_required, name:'Buyer info', description:'Set Service buyer info required', module: 'service', parameter:[]},
|
|
75
|
+
{permissionIndex:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service', parameter:[]},
|
|
76
|
+
{permissionIndex:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: 'service', parameter:[]},
|
|
77
|
+
{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:[]},
|
|
78
|
+
|
|
79
|
+
{permissionIndex:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: 'demand', parameter:[]},
|
|
80
|
+
{permissionIndex:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: 'demand', parameter:[]},
|
|
81
|
+
{permissionIndex:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'Expand Demand deadline', module: 'demand', parameter:[]},
|
|
82
|
+
{permissionIndex:PermissionIndex.demand_guard, name:'Guard', description:'Set Demand guard', module: 'demand', parameter:[]},
|
|
83
|
+
{permissionIndex:PermissionIndex.demand_description, name:'Description', description:'Set Demand description', module: 'demand', parameter:[]},
|
|
84
|
+
{permissionIndex:PermissionIndex.demand_yes, name:'Yes', description:'Pick the Deamand serice', module: 'demand', parameter:[]},
|
|
85
|
+
|
|
86
|
+
{permissionIndex:PermissionIndex.machine, name: 'Machine', description:'Launch new Machine', module: 'machine', parameter:[]},
|
|
87
|
+
{permissionIndex:PermissionIndex.machine_description, name: 'Description', description:'Set Machine description', module: 'machine', parameter:[]},
|
|
88
|
+
{permissionIndex:PermissionIndex.machine_repository, name: 'Repository', description:'Set Machine repository', module: 'machine', parameter:[]},
|
|
89
|
+
{permissionIndex:PermissionIndex.machine_clone, name: 'Clone', description:'Clone Machine', module: 'machine', parameter:[]},
|
|
90
|
+
{permissionIndex:PermissionIndex.machine_node, name: 'Node', description:'Set Machine nodes', module: 'machine', parameter:[]},
|
|
91
|
+
{permissionIndex:PermissionIndex.machine_endpoint, name: 'Endpoint', description:'Set Machine endpoint', module: 'machine', parameter:[]},
|
|
92
|
+
{permissionIndex:PermissionIndex.machine_pause, name: 'Pause', description:'Pause/Unpause Machine', module: 'machine', parameter:[]},
|
|
93
|
+
{permissionIndex:PermissionIndex.machine_publish, name: 'Publish', description:'Allowing the creation of Progress', module: 'machine', parameter:[]},
|
|
94
|
+
|
|
95
|
+
{permissionIndex:PermissionIndex.progress, name: 'Progress', description:'Launch new Progress', module: 'progress', parameter:[]},
|
|
96
|
+
{permissionIndex:PermissionIndex.progress_namedOperator, name: 'Operator', description:'Set Progress operators', module: 'progress', parameter:[]},
|
|
97
|
+
{permissionIndex:PermissionIndex.progress_bind_task, name: 'Bind', description:'Set Progress task', module: 'progress', parameter:[]},
|
|
98
|
+
{permissionIndex:PermissionIndex.progress_context_repository, name: 'Repository', description:'Set Progress repository', module: 'progress', parameter:[]},
|
|
99
|
+
{permissionIndex:PermissionIndex.progress_unhold, name: 'Unhold', description:'Release Progress holdings', module: 'progress', parameter:[]},
|
|
100
|
+
{permissionIndex:PermissionIndex.progress_parent, name: 'Parent', description:'Set Progress parent', module: 'progress', parameter:[]},
|
|
101
|
+
|
|
102
|
+
{permissionIndex:PermissionIndex.treasury, name: 'Treasury', description:'Launch new Treasury', module: 'treasury', parameter:[]},
|
|
103
|
+
{permissionIndex:PermissionIndex.treasury_deposit, name: 'Deposit', description:'Deposit coins', module: 'treasury', parameter:[]},
|
|
104
|
+
{permissionIndex:PermissionIndex.treasury_receive, name: 'Receive', description:'Receive coins from some address sent', module: 'treasury', parameter:[]},
|
|
105
|
+
{permissionIndex:PermissionIndex.treasury_withdraw, name: 'Withdraw', description:'Withdraw coins', module: 'treasury', parameter:[]},
|
|
106
|
+
{permissionIndex:PermissionIndex.treasury_withdraw_guard, name: 'Withdraw Guard', description:'Add/Remove Treasury withdraw guard', module: 'treasury', parameter:[]},
|
|
107
|
+
{permissionIndex:PermissionIndex.treasury_withdraw_mode, name: 'Withdraw mode', description:'Set Treasury withdraw mode', module: 'treasury', parameter:[]},
|
|
108
|
+
{permissionIndex:PermissionIndex.treasury_deposit_guard, name: 'Deposit Guard', description:'Set Treasury deposit guard', module: 'treasury', parameter:[]},
|
|
109
|
+
{permissionIndex:PermissionIndex.treasury_descritption, name: 'Description', description:'Set Treasury description', module: 'treasury', parameter:[]},
|
|
110
|
+
|
|
111
|
+
{permissionIndex:PermissionIndex.arbitration, name: 'Arbitration', description:'Launch new Arbitration', module: 'arbitration', parameter:[]},
|
|
112
|
+
{permissionIndex:PermissionIndex.arbitration_description, name: 'Description', description:'Set Arbitration description', module: 'arbitration', parameter:[]},
|
|
113
|
+
{permissionIndex:PermissionIndex.arbitration_endpoint, name: 'Endpoint', description:'Set Arbitration endpoint', module: 'arbitration', parameter:[]},
|
|
114
|
+
{permissionIndex:PermissionIndex.arbitration_fee, name: 'Fee', description:'Set Arbitration fee', module: 'arbitration', parameter:[]},
|
|
115
|
+
{permissionIndex:PermissionIndex.arbitration_guard, name: 'Guard', description:'Set Guard to apply for arbitration', module: 'arbitration', parameter:[]},
|
|
116
|
+
{permissionIndex:PermissionIndex.arbitration_arbitration, name: 'Arbitrate', description:'Determine the outcome of arbitration', module: 'arbitration', parameter:[]},
|
|
117
|
+
{permissionIndex:PermissionIndex.arbitration_pause, name: 'Pause', description:'Allowing/forbidding the creation of Arb', module: 'arbitration', parameter:[]},
|
|
118
|
+
{permissionIndex:PermissionIndex.arbitration_voting_guard, name: 'Voting Guard', description:'Add/Remove voting Guard', module: 'arbitration', parameter:[]},
|
|
119
|
+
{permissionIndex:PermissionIndex.arbitration_vote, name: 'Vote', description:'Vote on the application for arbitration', module: 'arbitration', parameter:[]},
|
|
120
|
+
{permissionIndex:PermissionIndex.arbitration_withdraw, name: 'Withdraw', description:'Withdraw the arbitration fee', module: 'arbitration', parameter:[]},
|
|
121
|
+
{permissionIndex:PermissionIndex.arbitration_treasury, name: 'Withdraw', description:'Set Treasury that fees was collected at the time of withdrawal', module: 'arbitration', parameter:[]},
|
|
122
|
+
]
|
|
123
|
+
export namespace Call {
|
|
124
|
+
|
|
125
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Provide AI with Basic WoWok event queries:
|
|
4
|
+
* for real-time detail tracking.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Protocol } from '../protocol';
|
|
8
|
+
|
|
9
|
+
export interface EventQueryOption {
|
|
10
|
+
/** optional paging cursor */
|
|
11
|
+
cursor?: {eventSeq: string; txDigest: string} | null | undefined;
|
|
12
|
+
/** maximum number of items per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. */
|
|
13
|
+
limit?: number | null | undefined;
|
|
14
|
+
/** query result ordering, default to false (ascending order), oldest record first. */
|
|
15
|
+
order?: 'ascending' | 'descending' | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface EventBase {
|
|
19
|
+
id: {eventSeq: string; txDigest: string};
|
|
20
|
+
sender: string;
|
|
21
|
+
type: string | 'NewArbEvent' | 'NewOrderEvent' | 'NewProgressEvent' | 'PresentServiceEvent';
|
|
22
|
+
type_raw: string;
|
|
23
|
+
time: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface NewArbEvent extends EventBase {
|
|
27
|
+
arb: string,
|
|
28
|
+
arbitration: string,
|
|
29
|
+
order: string,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface NewOrderEvent extends EventBase {
|
|
33
|
+
order: string,
|
|
34
|
+
service: string,
|
|
35
|
+
progress?: string | null,
|
|
36
|
+
amount: string,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface NewProgressEvent extends EventBase {
|
|
40
|
+
progress: string,
|
|
41
|
+
machine: string,
|
|
42
|
+
task?: string | null,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PresentServiceEvent extends EventBase {
|
|
46
|
+
demand: string,
|
|
47
|
+
service: string,
|
|
48
|
+
recommendation: string,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface EventAnswer {
|
|
52
|
+
data: EventBase[];
|
|
53
|
+
hasNextPage: boolean;
|
|
54
|
+
nextCursor?: {eventSeq: string; txDigest: string} | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export namespace EVENT_QUERY {
|
|
58
|
+
export const newArbEvents = async(option?:EventQueryOption) : Promise<EventAnswer> => {
|
|
59
|
+
return await queryEvents(Protocol.Instance().Package('wowok') + '::arb::NewArbEvent', option)
|
|
60
|
+
}
|
|
61
|
+
export const presentServiceEvents = async(option?:EventQueryOption) : Promise<EventAnswer> => {
|
|
62
|
+
return await queryEvents(Protocol.Instance().Package('wowok') + '::demand::PresentEvent', option)
|
|
63
|
+
}
|
|
64
|
+
export const newProgressEvents = async(option?:EventQueryOption) : Promise<EventAnswer> => {
|
|
65
|
+
return await queryEvents(Protocol.Instance().Package('wowok') + '::progress::NewProgressEvent', option)
|
|
66
|
+
}
|
|
67
|
+
export const newOrderEvents = async(option?:EventQueryOption) : Promise<EventAnswer> => {
|
|
68
|
+
return await queryEvents(Protocol.Instance().Package('wowok') + '::order::NewOrderEvent', option)
|
|
69
|
+
}
|
|
70
|
+
const queryEvents = async(type:string, option?:EventQueryOption) : Promise<EventAnswer> => {
|
|
71
|
+
const res = await Protocol.Client().queryEvents({query:{MoveEventType:type}, cursor:option?.cursor, limit:option?.limit, order:option?.order});
|
|
72
|
+
const data = res?.data?.map((v:any) => {
|
|
73
|
+
if (v?.packageId === Protocol.Instance().Package('wowok')) {
|
|
74
|
+
if (v?.type?.includes('::order::NewOrderEvent')) {
|
|
75
|
+
return {
|
|
76
|
+
id: v?.id, time: v?.timestampMs, type_raw:v?.type, sender:v?.sender, type:'NewOrderEvent',
|
|
77
|
+
order: v?.parsedJson?.object, service: v?.parsedJson?.service, progress: v?.parsedJson?.progress, amount: v?.parsedJson?.amount
|
|
78
|
+
} as NewOrderEvent
|
|
79
|
+
} else if (v?.type?.includes('::demand::PresentEvent')) {
|
|
80
|
+
return {
|
|
81
|
+
id: v?.id, time: v?.timestampMs, type_raw:v?.type, sender:v?.sender, type:'NewOrderEvent',
|
|
82
|
+
demand:v?.parsedJson?.object, service: v?.parsedJson?.service, recommendation:v?.parsedJson?.tips
|
|
83
|
+
} as PresentServiceEvent
|
|
84
|
+
} else if (v?.type?.includes('::progress::NewProgressEvent')) {
|
|
85
|
+
return {
|
|
86
|
+
id: v?.id, time: v?.timestampMs, type_raw:v?.type, sender:v?.sender, type:'NewOrderEvent',
|
|
87
|
+
progress:v?.parsedJson?.object, machine: v?.parsedJson?.machine, task:v?.parsedJson?.task
|
|
88
|
+
} as NewProgressEvent
|
|
89
|
+
} else if (v?.type?.includes('::arb::NewArbEvent')) {
|
|
90
|
+
return {
|
|
91
|
+
id: v?.id, time: v?.timestampMs, type_raw:v?.type, sender:v?.sender, type:'NewOrderEvent',
|
|
92
|
+
arb:v?.parsedJson?.object, arbitration:v?.parsedJson?.arbitration, order:v?.parsedJson?.order
|
|
93
|
+
} as NewArbEvent
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {id: v?.id, time: v?.timestampMs, type_raw:v?.type, sender:v?.sender, type:'',}
|
|
97
|
+
})
|
|
98
|
+
return {data:data, hasNextPage:res?.hasNextPage, nextCursor:res?.nextCursor}
|
|
99
|
+
}
|
|
100
|
+
}
|