@t2000/id 9.3.1 → 9.5.0

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/index.cjs CHANGED
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var bcs = require('@mysten/sui/bcs');
4
+ var grpc = require('@mysten/sui/grpc');
3
5
  var transactions = require('@mysten/sui/transactions');
6
+ var utils = require('@mysten/sui/utils');
4
7
 
5
8
  // src/index.ts
6
9
  var AGENT_ID_PACKAGE_ID = process.env.AGENT_ID_PACKAGE_ID ?? "0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451";
@@ -69,6 +72,34 @@ function buildRenounceOwnershipTx(agent) {
69
72
  });
70
73
  return tx;
71
74
  }
75
+ async function getAgentRecord(address, opts = {}) {
76
+ const network = opts.network ?? "mainnet";
77
+ const client = opts.client ?? new grpc.SuiGrpcClient({
78
+ baseUrl: network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io",
79
+ network
80
+ });
81
+ const reg = await client.core.getObject({
82
+ objectId: AGENT_ID_REGISTRY_ID,
83
+ include: { json: true }
84
+ });
85
+ const tableId = reg.object?.json?.agents?.id;
86
+ if (!tableId) return null;
87
+ const fieldId = utils.deriveDynamicFieldID(
88
+ tableId,
89
+ "address",
90
+ bcs.bcs.Address.serialize(address).toBytes()
91
+ );
92
+ try {
93
+ const obj = await client.core.getObject({
94
+ objectId: fieldId,
95
+ include: { json: true }
96
+ });
97
+ const rec = obj.object?.json?.value;
98
+ return rec?.agent ? rec : null;
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
72
103
  function buildSetActiveTx(agent, active) {
73
104
  const tx = new transactions.Transaction();
74
105
  tx.moveCall({
@@ -91,5 +122,6 @@ exports.buildRenounceOwnershipTx = buildRenounceOwnershipTx;
91
122
  exports.buildSetActiveTx = buildSetActiveTx;
92
123
  exports.buildSetPendingOwnerTx = buildSetPendingOwnerTx;
93
124
  exports.buildUpdateTx = buildUpdateTx;
125
+ exports.getAgentRecord = getAgentRecord;
94
126
  //# sourceMappingURL=index.cjs.map
95
127
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["Transaction"],"mappings":";;;;;AAgBO,IAAM,mBAAA,GACX,OAAA,CAAQ,GAAA,CAAI,mBAAA,IACZ;AAGK,IAAM,oBAAA,GACX,OAAA,CAAQ,GAAA,CAAI,oBAAA,IACZ;AAEF,IAAM,QAAA,GAAW,KAAA;AACjB,IAAM,MAAA,GAAS,UAAA;AAWf,SAAS,gBAAA,CAAiB,IAAiB,GAAA,EAAwB;AACjE,EAAA,OAAO;AAAA,IACL,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,IAC9B,GAAG,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,GAAA,CAAI,eAAe,IAAI,CAAA;AAAA,IAChD,GAAG,IAAA,CAAK,MAAA,CAAO,UAAU,GAAA,CAAI,cAAA,IAAkB,EAAE,CAAA;AAAA,IACjD,GAAG,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,GAAA,CAAI,OAAO,IAAI,CAAA;AAAA,IACxC,GAAG,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,GAAA,CAAI,eAAe,IAAI,CAAA;AAAA,IAChD,EAAA,CAAG,OAAO,QAAQ;AAAA,GACpB;AACF;AAGO,SAAS,eAAA,CAAgB,GAAA,GAAyB,EAAC,EAAgB;AACxE,EAAA,MAAM,EAAA,GAAK,IAAIA,wBAAA,EAAY;AAC3B,EAAA,EAAA,CAAG,QAAA,CAAS;AAAA,IACV,MAAA,EAAQ,CAAA,EAAG,mBAAmB,CAAA,EAAA,EAAK,MAAM,CAAA,UAAA,CAAA;AAAA,IACzC,SAAA,EAAW,gBAAA,CAAiB,EAAA,EAAI,GAAG;AAAA,GACpC,CAAA;AACD,EAAA,OAAO,EAAA;AACT;AAGO,SAAS,aAAA,CAAc,GAAA,G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Y;AAC3B,EAAA,EAAA,CAAG,QAAA,CAAS;AAAA,IACV,MAAA,EAAQ,CAAA,EAAG,mBAAmB,CAAA,EAAA,EAAK,MAAM,CAAA,oBAAA,CAAA;AAAA,IACzC,SAAA,EAAW;AAAA,MACT,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,MAC9B,EAAA,CAAG,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAAA,MACrB,EAAA,CAAG,OAAO,QAAQ;AAAA;AACpB,GACD,CAAA;AACD,EAAA,OAAO,EAAA;AACT;AAGO,SAAS,gBAAA,CAAiB,OAAe,MAAA,EAA8B;AAC5E,EAAA,MAAM,EAAA,GAAK,IAAIA,wBAAA,EAAY;AAC3B,EAAA,EAAA,CAAG,QAAA,CAAS;AAAA,IACV,MAAA,EAAQ,CAAA,EAAG,mBAAmB,CAAA,EAAA,EAAK,MAAM,CAAA,YAAA,CAAA;AAAA,IACzC,SAAA,EAAW;AAAA,MACT,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,MAC9B,EAAA,CAAG,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAAA,MACrB,EAAA,CAAG,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AAAA,MACnB,EAAA,CAAG,OAAO,QAAQ;AAAA;AACpB,GACD,CAAA;AACD,EAAA,OAAO,EAAA;AACT","file":"index.cjs","sourcesContent":["import { Transaction } from '@mysten/sui/transactions';\n\n/**\n * @t2000/id — client for the `agent_id::registry` Move package (Agent ID\n * Phase B). These builders construct UNSIGNED transactions calling the on-chain\n * registry; the caller signs (the agent's keypair for register/update/active;\n * the proposed owner for confirm) and may sponsor gas (the agent is the sender,\n * so `sender == agent` auth holds; a SUI-funded t2000 account co-signs gas).\n *\n * Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.\n */\n\n/** The published `agent_id` package id — the LATEST version (v2, the\n * 2026-07-09 additive upgrade that added `renounce_ownership`; the shared\n * Registry object is unchanged). The original v1 package\n * (`0x7669be20…be9a45e9`) remains callable for its own functions. */\nexport const AGENT_ID_PACKAGE_ID =\n process.env.AGENT_ID_PACKAGE_ID ??\n '0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451';\n\n/** The shared `Registry` object id. */\nexport const AGENT_ID_REGISTRY_ID =\n process.env.AGENT_ID_REGISTRY_ID ??\n '0xf41683aa9f4c121f34e4082c35180b0efdbd6d5293e3c88b1bcfa45ddf5c4119';\n\nconst CLOCK_ID = '0x6';\nconst MODULE = 'registry';\n\n/** The mutable registration payload. `update` is full-replace — supply the\n * complete desired state (omitted fields clear on-chain). */\nexport interface AgentRegistration {\n mcpEndpoint?: string | null;\n paymentMethods?: string[];\n did?: string | null;\n metadataUri?: string | null;\n}\n\nfunction registrationArgs(tx: Transaction, reg: AgentRegistration) {\n return [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.option('string', reg.mcpEndpoint ?? null),\n tx.pure.vector('string', reg.paymentMethods ?? []),\n tx.pure.option('string', reg.did ?? null),\n tx.pure.option('string', reg.metadataUri ?? null),\n tx.object(CLOCK_ID),\n ];\n}\n\n/** Register the SIGNER as an agent (self-sovereign: `sender == agent`). */\nexport function buildRegisterTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::register`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** Update the signer's record (full-replace). */\nexport function buildUpdateTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::update`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** The agent (signer) proposes an owner; nothing binds until the owner confirms. */\nexport function buildSetPendingOwnerTx(owner: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_pending_owner`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(owner),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The proposed owner (signer) confirms ownership of `agent`. */\nexport function buildConfirmOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::confirm_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The confirmed owner (signer) renounces ownership of `agent` — the record\n * returns to autonomous (`owner = none`). Re-linking is the normal two-sided\n * flow (the agent proposes, the owner confirms). Requires package v2+. */\nexport function buildRenounceOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::renounce_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** Toggle an agent's active flag (signer must be the agent or its owner). */\nexport function buildSetActiveTx(agent: string, active: boolean): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_active`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.pure.bool(active),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["Transaction","SuiGrpcClient","deriveDynamicFieldID","bcs"],"mappings":";;;;;;;;AAmBO,IAAM,mBAAA,GACX,OAAA,CAAQ,GAAA,CAAI,mBAAA,IACZ;AAGK,IAAM,oBAAA,GACX,OAAA,CAAQ,GAAA,CAAI,oBAAA,IACZ;AAEF,IAAM,QAAA,GAAW,KAAA;AACjB,IAAM,MAAA,GAAS,UAAA;AAWf,SAAS,gBAAA,CAAiB,IAAiB,GAAA,EAAwB;AACjE,EAAA,OAAO;AAAA,IACL,EAAA,CA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ACzC,SAAA,EAAW;AAAA,MACT,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,MAC9B,EAAA,CAAG,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAAA,MACrB,EAAA,CAAG,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AAAA,MACnB,EAAA,CAAG,OAAO,QAAQ;AAAA;AACpB,GACD,CAAA;AACD,EAAA,OAAO,EAAA;AACT","file":"index.cjs","sourcesContent":["import { bcs } from '@mysten/sui/bcs';\nimport { SuiGrpcClient } from '@mysten/sui/grpc';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { deriveDynamicFieldID } from '@mysten/sui/utils';\n\n/**\n * @t2000/id — client for the `agent_id::registry` Move package (Agent ID\n * Phase B). These builders construct UNSIGNED transactions calling the on-chain\n * registry; the caller signs (the agent's keypair for register/update/active;\n * the proposed owner for confirm) and may sponsor gas (the agent is the sender,\n * so `sender == agent` auth holds; a SUI-funded t2000 account co-signs gas).\n *\n * Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.\n */\n\n/** The published `agent_id` package id — the LATEST version (v2, the\n * 2026-07-09 additive upgrade that added `renounce_ownership`; the shared\n * Registry object is unchanged). The original v1 package\n * (`0x7669be20…be9a45e9`) remains callable for its own functions. */\nexport const AGENT_ID_PACKAGE_ID =\n process.env.AGENT_ID_PACKAGE_ID ??\n '0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451';\n\n/** The shared `Registry` object id. */\nexport const AGENT_ID_REGISTRY_ID =\n process.env.AGENT_ID_REGISTRY_ID ??\n '0xf41683aa9f4c121f34e4082c35180b0efdbd6d5293e3c88b1bcfa45ddf5c4119';\n\nconst CLOCK_ID = '0x6';\nconst MODULE = 'registry';\n\n/** The mutable registration payload. `update` is full-replace — supply the\n * complete desired state (omitted fields clear on-chain). */\nexport interface AgentRegistration {\n mcpEndpoint?: string | null;\n paymentMethods?: string[];\n did?: string | null;\n metadataUri?: string | null;\n}\n\nfunction registrationArgs(tx: Transaction, reg: AgentRegistration) {\n return [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.option('string', reg.mcpEndpoint ?? null),\n tx.pure.vector('string', reg.paymentMethods ?? []),\n tx.pure.option('string', reg.did ?? null),\n tx.pure.option('string', reg.metadataUri ?? null),\n tx.object(CLOCK_ID),\n ];\n}\n\n/** Register the SIGNER as an agent (self-sovereign: `sender == agent`). */\nexport function buildRegisterTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::register`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** Update the signer's record (full-replace). */\nexport function buildUpdateTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::update`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** The agent (signer) proposes an owner; nothing binds until the owner confirms. */\nexport function buildSetPendingOwnerTx(owner: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_pending_owner`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(owner),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The proposed owner (signer) confirms ownership of `agent`. */\nexport function buildConfirmOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::confirm_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The confirmed owner (signer) renounces ownership of `agent` — the record\n * returns to autonomous (`owner = none`). Re-linking is the normal two-sided\n * flow (the agent proposes, the owner confirms). Requires package v2+. */\nexport function buildRenounceOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::renounce_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** An agent's on-chain registry record (registry Table dynamic field),\n * field names as stored by the Move package. */\nexport interface OnChainAgentRecord {\n agent: string;\n mcp_endpoint?: string | null;\n payment_methods?: string[] | null;\n did?: string | null;\n metadata_uri?: string | null;\n}\n\n/**\n * Read one agent's registry record. Returns `null` when the address is not\n * registered. gRPC only (JSON-RPC is deactivated July 31, 2026).\n *\n * Callers that already hold a `SuiGrpcClient` should pass it; otherwise a\n * mainnet client is constructed per call.\n */\nexport async function getAgentRecord(\n address: string,\n opts: { client?: SuiGrpcClient; network?: 'mainnet' | 'testnet' } = {},\n): Promise<OnChainAgentRecord | null> {\n const network = opts.network ?? 'mainnet';\n const client =\n opts.client ??\n new SuiGrpcClient({\n baseUrl:\n network === 'testnet'\n ? 'https://fullnode.testnet.sui.io'\n : 'https://fullnode.mainnet.sui.io',\n network,\n });\n const reg = await client.core.getObject({\n objectId: AGENT_ID_REGISTRY_ID,\n include: { json: true },\n });\n const tableId = (reg.object?.json as { agents?: { id?: string } } | undefined)\n ?.agents?.id;\n if (!tableId) return null;\n const fieldId = deriveDynamicFieldID(\n tableId,\n 'address',\n bcs.Address.serialize(address).toBytes(),\n );\n try {\n const obj = await client.core.getObject({\n objectId: fieldId,\n include: { json: true },\n });\n const rec = (obj.object?.json as { value?: OnChainAgentRecord } | undefined)\n ?.value;\n return rec?.agent ? rec : null;\n } catch {\n // Field object absent → not registered.\n return null;\n }\n}\n\n/** Toggle an agent's active flag (signer must be the agent or its owner). */\nexport function buildSetActiveTx(agent: string, active: boolean): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_active`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.pure.bool(active),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
1
2
  import { Transaction } from '@mysten/sui/transactions';
2
3
 
3
4
  /**
@@ -36,7 +37,27 @@ declare function buildConfirmOwnershipTx(agent: string): Transaction;
36
37
  * returns to autonomous (`owner = none`). Re-linking is the normal two-sided
37
38
  * flow (the agent proposes, the owner confirms). Requires package v2+. */
38
39
  declare function buildRenounceOwnershipTx(agent: string): Transaction;
40
+ /** An agent's on-chain registry record (registry Table dynamic field),
41
+ * field names as stored by the Move package. */
42
+ interface OnChainAgentRecord {
43
+ agent: string;
44
+ mcp_endpoint?: string | null;
45
+ payment_methods?: string[] | null;
46
+ did?: string | null;
47
+ metadata_uri?: string | null;
48
+ }
49
+ /**
50
+ * Read one agent's registry record. Returns `null` when the address is not
51
+ * registered. gRPC only (JSON-RPC is deactivated July 31, 2026).
52
+ *
53
+ * Callers that already hold a `SuiGrpcClient` should pass it; otherwise a
54
+ * mainnet client is constructed per call.
55
+ */
56
+ declare function getAgentRecord(address: string, opts?: {
57
+ client?: SuiGrpcClient;
58
+ network?: 'mainnet' | 'testnet';
59
+ }): Promise<OnChainAgentRecord | null>;
39
60
  /** Toggle an agent's active flag (signer must be the agent or its owner). */
40
61
  declare function buildSetActiveTx(agent: string, active: boolean): Transaction;
41
62
 
42
- export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx };
63
+ export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, type OnChainAgentRecord, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx, getAgentRecord };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
1
2
  import { Transaction } from '@mysten/sui/transactions';
2
3
 
3
4
  /**
@@ -36,7 +37,27 @@ declare function buildConfirmOwnershipTx(agent: string): Transaction;
36
37
  * returns to autonomous (`owner = none`). Re-linking is the normal two-sided
37
38
  * flow (the agent proposes, the owner confirms). Requires package v2+. */
38
39
  declare function buildRenounceOwnershipTx(agent: string): Transaction;
40
+ /** An agent's on-chain registry record (registry Table dynamic field),
41
+ * field names as stored by the Move package. */
42
+ interface OnChainAgentRecord {
43
+ agent: string;
44
+ mcp_endpoint?: string | null;
45
+ payment_methods?: string[] | null;
46
+ did?: string | null;
47
+ metadata_uri?: string | null;
48
+ }
49
+ /**
50
+ * Read one agent's registry record. Returns `null` when the address is not
51
+ * registered. gRPC only (JSON-RPC is deactivated July 31, 2026).
52
+ *
53
+ * Callers that already hold a `SuiGrpcClient` should pass it; otherwise a
54
+ * mainnet client is constructed per call.
55
+ */
56
+ declare function getAgentRecord(address: string, opts?: {
57
+ client?: SuiGrpcClient;
58
+ network?: 'mainnet' | 'testnet';
59
+ }): Promise<OnChainAgentRecord | null>;
39
60
  /** Toggle an agent's active flag (signer must be the agent or its owner). */
40
61
  declare function buildSetActiveTx(agent: string, active: boolean): Transaction;
41
62
 
42
- export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx };
63
+ export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, type OnChainAgentRecord, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx, getAgentRecord };
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
+ import { bcs } from '@mysten/sui/bcs';
2
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
1
3
  import { Transaction } from '@mysten/sui/transactions';
4
+ import { deriveDynamicFieldID } from '@mysten/sui/utils';
2
5
 
3
6
  // src/index.ts
4
7
  var AGENT_ID_PACKAGE_ID = process.env.AGENT_ID_PACKAGE_ID ?? "0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451";
@@ -67,6 +70,34 @@ function buildRenounceOwnershipTx(agent) {
67
70
  });
68
71
  return tx;
69
72
  }
73
+ async function getAgentRecord(address, opts = {}) {
74
+ const network = opts.network ?? "mainnet";
75
+ const client = opts.client ?? new SuiGrpcClient({
76
+ baseUrl: network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io",
77
+ network
78
+ });
79
+ const reg = await client.core.getObject({
80
+ objectId: AGENT_ID_REGISTRY_ID,
81
+ include: { json: true }
82
+ });
83
+ const tableId = reg.object?.json?.agents?.id;
84
+ if (!tableId) return null;
85
+ const fieldId = deriveDynamicFieldID(
86
+ tableId,
87
+ "address",
88
+ bcs.Address.serialize(address).toBytes()
89
+ );
90
+ try {
91
+ const obj = await client.core.getObject({
92
+ objectId: fieldId,
93
+ include: { json: true }
94
+ });
95
+ const rec = obj.object?.json?.value;
96
+ return rec?.agent ? rec : null;
97
+ } catch {
98
+ return null;
99
+ }
100
+ }
70
101
  function buildSetActiveTx(agent, active) {
71
102
  const tx = new Transaction();
72
103
  tx.moveCall({
@@ -81,6 +112,6 @@ function buildSetActiveTx(agent, active) {
81
112
  return tx;
82
113
  }
83
114
 
84
- export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx };
115
+ export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx, getAgentRecord };
85
116
  //# sourceMappingURL=index.js.map
86
117
  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AK,MAAM,CAAA,oBAAA,CAAA;AAAA,IACzC,SAAA,EAAW;AAAA,MACT,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,MAC9B,EAAA,CAAG,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAAA,MACrB,EAAA,CAAG,OAAO,QAAQ;AAAA;AACpB,GACD,CAAA;AACD,EAAA,OAAO,EAAA;AACT;AAGO,SAAS,gBAAA,CAAiB,OAAe,MAAA,EAA8B;AAC5E,EAAA,MAAM,EAAA,GAAK,IAAI,WAAA,EAAY;AAC3B,EAAA,EAAA,CAAG,QAAA,CAAS;AAAA,IACV,MAAA,EAAQ,CAAA,EAAG,mBAAmB,CAAA,EAAA,EAAK,MAAM,CAAA,YAAA,CAAA;AAAA,IACzC,SAAA,EAAW;AAAA,MACT,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,MAC9B,EAAA,CAAG,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAAA,MACrB,EAAA,CAAG,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AAAA,MACnB,EAAA,CAAG,OAAO,QAAQ;AAAA;AACpB,GACD,CAAA;AACD,EAAA,OAAO,EAAA;AACT","file":"index.js","sourcesContent":["import { Transaction } from '@mysten/sui/transactions';\n\n/**\n * @t2000/id — client for the `agent_id::registry` Move package (Agent ID\n * Phase B). These builders construct UNSIGNED transactions calling the on-chain\n * registry; the caller signs (the agent's keypair for register/update/active;\n * the proposed owner for confirm) and may sponsor gas (the agent is the sender,\n * so `sender == agent` auth holds; a SUI-funded t2000 account co-signs gas).\n *\n * Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.\n */\n\n/** The published `agent_id` package id — the LATEST version (v2, the\n * 2026-07-09 additive upgrade that added `renounce_ownership`; the shared\n * Registry object is unchanged). The original v1 package\n * (`0x7669be20…be9a45e9`) remains callable for its own functions. */\nexport const AGENT_ID_PACKAGE_ID =\n process.env.AGENT_ID_PACKAGE_ID ??\n '0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451';\n\n/** The shared `Registry` object id. */\nexport const AGENT_ID_REGISTRY_ID =\n process.env.AGENT_ID_REGISTRY_ID ??\n '0xf41683aa9f4c121f34e4082c35180b0efdbd6d5293e3c88b1bcfa45ddf5c4119';\n\nconst CLOCK_ID = '0x6';\nconst MODULE = 'registry';\n\n/** The mutable registration payload. `update` is full-replace — supply the\n * complete desired state (omitted fields clear on-chain). */\nexport interface AgentRegistration {\n mcpEndpoint?: string | null;\n paymentMethods?: string[];\n did?: string | null;\n metadataUri?: string | null;\n}\n\nfunction registrationArgs(tx: Transaction, reg: AgentRegistration) {\n return [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.option('string', reg.mcpEndpoint ?? null),\n tx.pure.vector('string', reg.paymentMethods ?? []),\n tx.pure.option('string', reg.did ?? null),\n tx.pure.option('string', reg.metadataUri ?? null),\n tx.object(CLOCK_ID),\n ];\n}\n\n/** Register the SIGNER as an agent (self-sovereign: `sender == agent`). */\nexport function buildRegisterTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::register`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** Update the signer's record (full-replace). */\nexport function buildUpdateTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::update`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** The agent (signer) proposes an owner; nothing binds until the owner confirms. */\nexport function buildSetPendingOwnerTx(owner: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_pending_owner`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(owner),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The proposed owner (signer) confirms ownership of `agent`. */\nexport function buildConfirmOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::confirm_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The confirmed owner (signer) renounces ownership of `agent` — the record\n * returns to autonomous (`owner = none`). Re-linking is the normal two-sided\n * flow (the agent proposes, the owner confirms). Requires package v2+. */\nexport function buildRenounceOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::renounce_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** Toggle an agent's active flag (signer must be the agent or its owner). */\nexport function buildSetActiveTx(agent: string, active: boolean): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_active`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.pure.bool(active),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAmBO,IAAM,mBAAA,GACX,OAAA,CAAQ,GAAA,CAAI,mBAAA,IACZ;AAGK,IAAM,oBAAA,GACX,OAAA,CAAQ,GAAA,CAAI,oBAAA,IACZ;AAEF,IAAM,QAAA,GAAW,KAAA;AACjB,IAAM,MAAA,GAAS,UAAA;AAWf,SAAS,gBAAA,CAAiB,IAAiB,GAAA,EAAwB;AACjE,EAAA,OAAO;AAAA,IACL,EAAA,CAAG,OAAO,oBAAoB,CAAA;AAAA,IAC9B,GAAG,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,GAAA,CAAI,eAAe,IAAI,CAAA;AAAA,IAChD,GAAG,IAAA,CAAK,MAA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A,CAAK,MAAM,CAAA;AAAA,MACnB,EAAA,CAAG,OAAO,QAAQ;AAAA;AACpB,GACD,CAAA;AACD,EAAA,OAAO,EAAA;AACT","file":"index.js","sourcesContent":["import { bcs } from '@mysten/sui/bcs';\nimport { SuiGrpcClient } from '@mysten/sui/grpc';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { deriveDynamicFieldID } from '@mysten/sui/utils';\n\n/**\n * @t2000/id — client for the `agent_id::registry` Move package (Agent ID\n * Phase B). These builders construct UNSIGNED transactions calling the on-chain\n * registry; the caller signs (the agent's keypair for register/update/active;\n * the proposed owner for confirm) and may sponsor gas (the agent is the sender,\n * so `sender == agent` auth holds; a SUI-funded t2000 account co-signs gas).\n *\n * Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.\n */\n\n/** The published `agent_id` package id — the LATEST version (v2, the\n * 2026-07-09 additive upgrade that added `renounce_ownership`; the shared\n * Registry object is unchanged). The original v1 package\n * (`0x7669be20…be9a45e9`) remains callable for its own functions. */\nexport const AGENT_ID_PACKAGE_ID =\n process.env.AGENT_ID_PACKAGE_ID ??\n '0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451';\n\n/** The shared `Registry` object id. */\nexport const AGENT_ID_REGISTRY_ID =\n process.env.AGENT_ID_REGISTRY_ID ??\n '0xf41683aa9f4c121f34e4082c35180b0efdbd6d5293e3c88b1bcfa45ddf5c4119';\n\nconst CLOCK_ID = '0x6';\nconst MODULE = 'registry';\n\n/** The mutable registration payload. `update` is full-replace — supply the\n * complete desired state (omitted fields clear on-chain). */\nexport interface AgentRegistration {\n mcpEndpoint?: string | null;\n paymentMethods?: string[];\n did?: string | null;\n metadataUri?: string | null;\n}\n\nfunction registrationArgs(tx: Transaction, reg: AgentRegistration) {\n return [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.option('string', reg.mcpEndpoint ?? null),\n tx.pure.vector('string', reg.paymentMethods ?? []),\n tx.pure.option('string', reg.did ?? null),\n tx.pure.option('string', reg.metadataUri ?? null),\n tx.object(CLOCK_ID),\n ];\n}\n\n/** Register the SIGNER as an agent (self-sovereign: `sender == agent`). */\nexport function buildRegisterTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::register`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** Update the signer's record (full-replace). */\nexport function buildUpdateTx(reg: AgentRegistration = {}): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::update`,\n arguments: registrationArgs(tx, reg),\n });\n return tx;\n}\n\n/** The agent (signer) proposes an owner; nothing binds until the owner confirms. */\nexport function buildSetPendingOwnerTx(owner: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_pending_owner`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(owner),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The proposed owner (signer) confirms ownership of `agent`. */\nexport function buildConfirmOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::confirm_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** The confirmed owner (signer) renounces ownership of `agent` — the record\n * returns to autonomous (`owner = none`). Re-linking is the normal two-sided\n * flow (the agent proposes, the owner confirms). Requires package v2+. */\nexport function buildRenounceOwnershipTx(agent: string): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::renounce_ownership`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n\n/** An agent's on-chain registry record (registry Table dynamic field),\n * field names as stored by the Move package. */\nexport interface OnChainAgentRecord {\n agent: string;\n mcp_endpoint?: string | null;\n payment_methods?: string[] | null;\n did?: string | null;\n metadata_uri?: string | null;\n}\n\n/**\n * Read one agent's registry record. Returns `null` when the address is not\n * registered. gRPC only (JSON-RPC is deactivated July 31, 2026).\n *\n * Callers that already hold a `SuiGrpcClient` should pass it; otherwise a\n * mainnet client is constructed per call.\n */\nexport async function getAgentRecord(\n address: string,\n opts: { client?: SuiGrpcClient; network?: 'mainnet' | 'testnet' } = {},\n): Promise<OnChainAgentRecord | null> {\n const network = opts.network ?? 'mainnet';\n const client =\n opts.client ??\n new SuiGrpcClient({\n baseUrl:\n network === 'testnet'\n ? 'https://fullnode.testnet.sui.io'\n : 'https://fullnode.mainnet.sui.io',\n network,\n });\n const reg = await client.core.getObject({\n objectId: AGENT_ID_REGISTRY_ID,\n include: { json: true },\n });\n const tableId = (reg.object?.json as { agents?: { id?: string } } | undefined)\n ?.agents?.id;\n if (!tableId) return null;\n const fieldId = deriveDynamicFieldID(\n tableId,\n 'address',\n bcs.Address.serialize(address).toBytes(),\n );\n try {\n const obj = await client.core.getObject({\n objectId: fieldId,\n include: { json: true },\n });\n const rec = (obj.object?.json as { value?: OnChainAgentRecord } | undefined)\n ?.value;\n return rec?.agent ? rec : null;\n } catch {\n // Field object absent → not registered.\n return null;\n }\n}\n\n/** Toggle an agent's active flag (signer must be the agent or its owner). */\nexport function buildSetActiveTx(agent: string, active: boolean): Transaction {\n const tx = new Transaction();\n tx.moveCall({\n target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_active`,\n arguments: [\n tx.object(AGENT_ID_REGISTRY_ID),\n tx.pure.address(agent),\n tx.pure.bool(active),\n tx.object(CLOCK_ID),\n ],\n });\n return tx;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t2000/id",
3
- "version": "9.3.1",
3
+ "version": "9.5.0",
4
4
  "description": "Agent ID — on-chain agent identity registry client for the t2000 stack (Sui). Build register/update/ownership/active transactions against the agent_id::registry Move package.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",