Sign In

@t2000/id

Package Overview
Dependencies
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@t2000/id - npm Package Compare versions

Comparing version
10.30.5
to
10.31.0
+1
-40
dist/index.cjs

@@ -9,3 +9,3 @@ 'use strict';

// src/index.ts
var AGENT_ID_PACKAGE_ID = process.env.AGENT_ID_PACKAGE_ID ?? "0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451";
var AGENT_ID_PACKAGE_ID = process.env.AGENT_ID_PACKAGE_ID ?? "0xe94a8b8f14104b75ee4c7e359289da78698fbfffdd0e5e3e9cb7d250887df7a7";
var AGENT_ID_REGISTRY_ID = process.env.AGENT_ID_REGISTRY_ID ?? "0xf41683aa9f4c121f34e4082c35180b0efdbd6d5293e3c88b1bcfa45ddf5c4119";

@@ -40,38 +40,2 @@ var CLOCK_ID = "0x6";

}
function buildSetPendingOwnerTx(owner) {
const tx = new transactions.Transaction();
tx.moveCall({
target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_pending_owner`,
arguments: [
tx.object(AGENT_ID_REGISTRY_ID),
tx.pure.address(owner),
tx.object(CLOCK_ID)
]
});
return tx;
}
function buildConfirmOwnershipTx(agent) {
const tx = new transactions.Transaction();
tx.moveCall({
target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::confirm_ownership`,
arguments: [
tx.object(AGENT_ID_REGISTRY_ID),
tx.pure.address(agent),
tx.object(CLOCK_ID)
]
});
return tx;
}
function buildRenounceOwnershipTx(agent) {
const tx = new transactions.Transaction();
tx.moveCall({
target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::renounce_ownership`,
arguments: [
tx.object(AGENT_ID_REGISTRY_ID),
tx.pure.address(agent),
tx.object(CLOCK_ID)
]
});
return tx;
}
async function getAgentRecord(address, opts = {}) {

@@ -121,7 +85,4 @@ const network = opts.network ?? "mainnet";

exports.AGENT_ID_REGISTRY_ID = AGENT_ID_REGISTRY_ID;
exports.buildConfirmOwnershipTx = buildConfirmOwnershipTx;
exports.buildRegisterTx = buildRegisterTx;
exports.buildRenounceOwnershipTx = buildRenounceOwnershipTx;
exports.buildSetActiveTx = buildSetActiveTx;
exports.buildSetPendingOwnerTx = buildSetPendingOwnerTx;
exports.buildUpdateTx = buildUpdateTx;

@@ -128,0 +89,0 @@ exports.getAgentRecord = getAgentRecord;

+1
-1

@@ -1,1 +0,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,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,CAA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A;AAAQ,GACzC;AACA,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,IAAA,CAAK,SAAA,CAAU;AAAA,MACtC,QAAA,EAAU,OAAA;AAAA,MACV,OAAA,EAAS,EAAE,IAAA,EAAM,IAAA;AAAK,KACvB,CAAA;AACD,IAAA,MAAM,GAAA,GAAO,GAAA,CAAI,MAAA,EAAQ,IAAA,EACrB,KAAA;AACJ,IAAA,OAAO,GAAA,EAAK,QAAQ,GAAA,GAAM,IAAA;AAAA,EAC5B,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAGO,SAAS,gBAAA,CAAiB,OAAe,MAAA,EAA8B;AAC5E,EAAA,MAAM,EAAA,GAAK,IAAIH,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 { 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"]}
{"version":3,"sources":["../src/index.ts"],"names":["Transaction","SuiGrpcClient","deriveDynamicFieldID","bcs"],"mappings":";;;;;;;;AA2BO,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,GAA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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 (always the AGENT's keypair — every mutator is\n * agent-signed since S.1032) 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 * Passport↔agent OWNERSHIP left the product (S.1032, 2026-08-13): the\n * link/confirm/renounce builders are gone, and the on-chain mutators\n * always abort (`EOwnershipDeprecated`) once the Registry is migrated.\n * Historical `owner`/`pending_owner` record fields remain on-chain, inert.\n *\n * Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.\n */\n\n/** The published `agent_id` package id — pin the LATEST upgrade id ONLY\n * (the S.1019 rule; event/type anchors stay on the original package\n * `0x7669be20…be9a45e9`, which remains callable for its own functions).\n * LATEST = the S.1032 v2 upgrade (2026-08-13, ownership deprecated;\n * Registry migrated to version 2 — upgrade digest 7ZUiRi48…, migrate\n * digest 97sNqgt9…). The previous id `0x78d36506…d15451` now aborts\n * EWrongVersion on every mutator. */\nexport const AGENT_ID_PACKAGE_ID =\n process.env.AGENT_ID_PACKAGE_ID ??\n '0xe94a8b8f14104b75ee4c7e359289da78698fbfffdd0e5e3e9cb7d250887df7a7';\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// Ownership builders (buildSetPendingOwnerTx / buildConfirmOwnershipTx /\n// buildRenounceOwnershipTx) were REMOVED in S.1032 — the on-chain mutators\n// always abort since registry v2. There is no ownership surface to build for.\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 itself —\n * agent-only since registry v2 / S.1032). */\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"]}

@@ -7,12 +7,20 @@ import { SuiGrpcClient } from '@mysten/sui/grpc';

* Phase B). These builders construct UNSIGNED transactions calling the on-chain
* registry; the caller signs (the agent's keypair for register/update/active;
* the proposed owner for confirm) and may sponsor gas (the agent is the sender,
* registry; the caller signs (always the AGENT's keypair — every mutator is
* agent-signed since S.1032) and may sponsor gas (the agent is the sender,
* so `sender == agent` auth holds; a SUI-funded t2000 account co-signs gas).
*
* Passport↔agent OWNERSHIP left the product (S.1032, 2026-08-13): the
* link/confirm/renounce builders are gone, and the on-chain mutators
* always abort (`EOwnershipDeprecated`) once the Registry is migrated.
* Historical `owner`/`pending_owner` record fields remain on-chain, inert.
*
* Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.
*/
/** The published `agent_id` package id — the LATEST version (v2, the
* 2026-07-09 additive upgrade that added `renounce_ownership`; the shared
* Registry object is unchanged). The original v1 package
* (`0x7669be20…be9a45e9`) remains callable for its own functions. */
/** The published `agent_id` package id — pin the LATEST upgrade id ONLY
* (the S.1019 rule; event/type anchors stay on the original package
* `0x7669be20…be9a45e9`, which remains callable for its own functions).
* LATEST = the S.1032 v2 upgrade (2026-08-13, ownership deprecated;
* Registry migrated to version 2 — upgrade digest 7ZUiRi48…, migrate
* digest 97sNqgt9…). The previous id `0x78d36506…d15451` now aborts
* EWrongVersion on every mutator. */
declare const AGENT_ID_PACKAGE_ID: string;

@@ -33,10 +41,2 @@ /** The shared `Registry` object id. */

declare function buildUpdateTx(reg?: AgentRegistration): Transaction;
/** The agent (signer) proposes an owner; nothing binds until the owner confirms. */
declare function buildSetPendingOwnerTx(owner: string): Transaction;
/** The proposed owner (signer) confirms ownership of `agent`. */
declare function buildConfirmOwnershipTx(agent: string): Transaction;
/** The confirmed owner (signer) renounces ownership of `agent` — the record
* returns to autonomous (`owner = none`). Re-linking is the normal two-sided
* flow (the agent proposes, the owner confirms). Requires package v2+. */
declare function buildRenounceOwnershipTx(agent: string): Transaction;
/** An agent's on-chain registry record (registry Table dynamic field),

@@ -62,5 +62,6 @@ * field names as stored by the Move package. */

}): Promise<OnChainAgentRecord | null>;
/** Toggle an agent's active flag (signer must be the agent or its owner). */
/** Toggle an agent's active flag (signer must be the agent itself —
* agent-only since registry v2 / S.1032). */
declare function buildSetActiveTx(agent: string, active: boolean): Transaction;
export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, type OnChainAgentRecord, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx, getAgentRecord };
export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, type OnChainAgentRecord, buildRegisterTx, buildSetActiveTx, buildUpdateTx, getAgentRecord };

@@ -7,12 +7,20 @@ import { SuiGrpcClient } from '@mysten/sui/grpc';

* Phase B). These builders construct UNSIGNED transactions calling the on-chain
* registry; the caller signs (the agent's keypair for register/update/active;
* the proposed owner for confirm) and may sponsor gas (the agent is the sender,
* registry; the caller signs (always the AGENT's keypair — every mutator is
* agent-signed since S.1032) and may sponsor gas (the agent is the sender,
* so `sender == agent` auth holds; a SUI-funded t2000 account co-signs gas).
*
* Passport↔agent OWNERSHIP left the product (S.1032, 2026-08-13): the
* link/confirm/renounce builders are gone, and the on-chain mutators
* always abort (`EOwnershipDeprecated`) once the Registry is migrated.
* Historical `owner`/`pending_owner` record fields remain on-chain, inert.
*
* Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.
*/
/** The published `agent_id` package id — the LATEST version (v2, the
* 2026-07-09 additive upgrade that added `renounce_ownership`; the shared
* Registry object is unchanged). The original v1 package
* (`0x7669be20…be9a45e9`) remains callable for its own functions. */
/** The published `agent_id` package id — pin the LATEST upgrade id ONLY
* (the S.1019 rule; event/type anchors stay on the original package
* `0x7669be20…be9a45e9`, which remains callable for its own functions).
* LATEST = the S.1032 v2 upgrade (2026-08-13, ownership deprecated;
* Registry migrated to version 2 — upgrade digest 7ZUiRi48…, migrate
* digest 97sNqgt9…). The previous id `0x78d36506…d15451` now aborts
* EWrongVersion on every mutator. */
declare const AGENT_ID_PACKAGE_ID: string;

@@ -33,10 +41,2 @@ /** The shared `Registry` object id. */

declare function buildUpdateTx(reg?: AgentRegistration): Transaction;
/** The agent (signer) proposes an owner; nothing binds until the owner confirms. */
declare function buildSetPendingOwnerTx(owner: string): Transaction;
/** The proposed owner (signer) confirms ownership of `agent`. */
declare function buildConfirmOwnershipTx(agent: string): Transaction;
/** The confirmed owner (signer) renounces ownership of `agent` — the record
* returns to autonomous (`owner = none`). Re-linking is the normal two-sided
* flow (the agent proposes, the owner confirms). Requires package v2+. */
declare function buildRenounceOwnershipTx(agent: string): Transaction;
/** An agent's on-chain registry record (registry Table dynamic field),

@@ -62,5 +62,6 @@ * field names as stored by the Move package. */

}): Promise<OnChainAgentRecord | null>;
/** Toggle an agent's active flag (signer must be the agent or its owner). */
/** Toggle an agent's active flag (signer must be the agent itself —
* agent-only since registry v2 / S.1032). */
declare function buildSetActiveTx(agent: string, active: boolean): Transaction;
export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, type OnChainAgentRecord, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx, getAgentRecord };
export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, type AgentRegistration, type OnChainAgentRecord, buildRegisterTx, buildSetActiveTx, buildUpdateTx, getAgentRecord };

@@ -7,3 +7,3 @@ import { bcs } from '@mysten/sui/bcs';

// src/index.ts
var AGENT_ID_PACKAGE_ID = process.env.AGENT_ID_PACKAGE_ID ?? "0x78d365066fb0e6468a9dcb49595e559434a53d7a12d845f776bcda76b4d15451";
var AGENT_ID_PACKAGE_ID = process.env.AGENT_ID_PACKAGE_ID ?? "0xe94a8b8f14104b75ee4c7e359289da78698fbfffdd0e5e3e9cb7d250887df7a7";
var AGENT_ID_REGISTRY_ID = process.env.AGENT_ID_REGISTRY_ID ?? "0xf41683aa9f4c121f34e4082c35180b0efdbd6d5293e3c88b1bcfa45ddf5c4119";

@@ -38,38 +38,2 @@ var CLOCK_ID = "0x6";

}
function buildSetPendingOwnerTx(owner) {
const tx = new Transaction();
tx.moveCall({
target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::set_pending_owner`,
arguments: [
tx.object(AGENT_ID_REGISTRY_ID),
tx.pure.address(owner),
tx.object(CLOCK_ID)
]
});
return tx;
}
function buildConfirmOwnershipTx(agent) {
const tx = new Transaction();
tx.moveCall({
target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::confirm_ownership`,
arguments: [
tx.object(AGENT_ID_REGISTRY_ID),
tx.pure.address(agent),
tx.object(CLOCK_ID)
]
});
return tx;
}
function buildRenounceOwnershipTx(agent) {
const tx = new Transaction();
tx.moveCall({
target: `${AGENT_ID_PACKAGE_ID}::${MODULE}::renounce_ownership`,
arguments: [
tx.object(AGENT_ID_REGISTRY_ID),
tx.pure.address(agent),
tx.object(CLOCK_ID)
]
});
return tx;
}
async function getAgentRecord(address, opts = {}) {

@@ -117,4 +81,4 @@ const network = opts.network ?? "mainnet";

export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, buildConfirmOwnershipTx, buildRegisterTx, buildRenounceOwnershipTx, buildSetActiveTx, buildSetPendingOwnerTx, buildUpdateTx, getAgentRecord };
export { AGENT_ID_PACKAGE_ID, AGENT_ID_REGISTRY_ID, buildRegisterTx, buildSetActiveTx, buildUpdateTx, getAgentRecord };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

@@ -1,1 +0,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,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,EA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;AAAA,IACd,OAAA;AAAA,IACA,SAAA;AAAA,IACA,GAAA,CAAI,OAAA,CAAQ,SAAA,CAAU,OAAO,EAAE,OAAA;AAAQ,GACzC;AACA,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,IAAA,CAAK,SAAA,CAAU;AAAA,MACtC,QAAA,EAAU,OAAA;AAAA,MACV,OAAA,EAAS,EAAE,IAAA,EAAM,IAAA;AAAK,KACvB,CAAA;AACD,IAAA,MAAM,GAAA,GAAO,GAAA,CAAI,MAAA,EAAQ,IAAA,EACrB,KAAA;AACJ,IAAA,OAAO,GAAA,EAAK,QAAQ,GAAA,GAAM,IAAA;AAAA,EAC5B,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;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 { 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"]}
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AA2BO,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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;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 (always the AGENT's keypair — every mutator is\n * agent-signed since S.1032) 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 * Passport↔agent OWNERSHIP left the product (S.1032, 2026-08-13): the\n * link/confirm/renounce builders are gone, and the on-chain mutators\n * always abort (`EOwnershipDeprecated`) once the Registry is migrated.\n * Historical `owner`/`pending_owner` record fields remain on-chain, inert.\n *\n * Deployed on Sui mainnet 2026-06-29. Override via env for testnet/dev.\n */\n\n/** The published `agent_id` package id — pin the LATEST upgrade id ONLY\n * (the S.1019 rule; event/type anchors stay on the original package\n * `0x7669be20…be9a45e9`, which remains callable for its own functions).\n * LATEST = the S.1032 v2 upgrade (2026-08-13, ownership deprecated;\n * Registry migrated to version 2 — upgrade digest 7ZUiRi48…, migrate\n * digest 97sNqgt9…). The previous id `0x78d36506…d15451` now aborts\n * EWrongVersion on every mutator. */\nexport const AGENT_ID_PACKAGE_ID =\n process.env.AGENT_ID_PACKAGE_ID ??\n '0xe94a8b8f14104b75ee4c7e359289da78698fbfffdd0e5e3e9cb7d250887df7a7';\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// Ownership builders (buildSetPendingOwnerTx / buildConfirmOwnershipTx /\n// buildRenounceOwnershipTx) were REMOVED in S.1032 — the on-chain mutators\n// always abort since registry v2. There is no ownership surface to build for.\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 itself —\n * agent-only since registry v2 / S.1032). */\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"]}
{
"name": "@t2000/id",
"version": "10.30.5",
"version": "10.31.0",
"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,0 +5,0 @@ "type": "module",

@@ -32,6 +32,8 @@ # @t2000/id

| `buildUpdateTx(reg?)` | `update` (full-replace) | the agent |
| `buildSetPendingOwnerTx(owner)` | `set_pending_owner` | the agent |
| `buildConfirmOwnershipTx(agent)` | `confirm_ownership` | the proposed owner |
| `buildSetActiveTx(agent, active)` | `set_active` | the agent or its owner |
| `buildSetActiveTx(agent, active)` | `set_active` | the agent |
Ownership builders were removed in v11 (S.1032) — Passport↔agent ownership
left the product; every registry mutator is agent-signed and the on-chain
ownership entrypoints always abort since registry v2.
Package + Registry object ids are baked in (mainnet) and overridable via `AGENT_ID_PACKAGE_ID` / `AGENT_ID_REGISTRY_ID` env vars for testnet/dev.

@@ -38,0 +40,0 @@