gbz185-sdk 0.1.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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/agent-maintenance.d.ts +35 -0
- package/dist/agent-maintenance.d.ts.map +1 -0
- package/dist/agent-maintenance.js +107 -0
- package/dist/agent-maintenance.js.map +1 -0
- package/dist/authorization.d.ts +32 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/authorization.js +37 -0
- package/dist/authorization.js.map +1 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +70 -0
- package/dist/client.js.map +1 -0
- package/dist/conformance.d.ts +11 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +195 -0
- package/dist/conformance.js.map +1 -0
- package/dist/credentials.d.ts +124 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +209 -0
- package/dist/credentials.js.map +1 -0
- package/dist/description-registry.d.ts +66 -0
- package/dist/description-registry.d.ts.map +1 -0
- package/dist/description-registry.js +137 -0
- package/dist/description-registry.js.map +1 -0
- package/dist/discovery.d.ts +14 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +105 -0
- package/dist/discovery.js.map +1 -0
- package/dist/factory.d.ts +34 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +98 -0
- package/dist/factory.js.map +1 -0
- package/dist/functional-architecture.d.ts +18 -0
- package/dist/functional-architecture.d.ts.map +1 -0
- package/dist/functional-architecture.js +159 -0
- package/dist/functional-architecture.js.map +1 -0
- package/dist/identity-code.d.ts +8 -0
- package/dist/identity-code.d.ts.map +1 -0
- package/dist/identity-code.js +76 -0
- package/dist/identity-code.js.map +1 -0
- package/dist/identity-registry.d.ts +68 -0
- package/dist/identity-registry.d.ts.map +1 -0
- package/dist/identity-registry.js +155 -0
- package/dist/identity-registry.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction.d.ts +41 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +95 -0
- package/dist/interaction.js.map +1 -0
- package/dist/message-distribution.d.ts +18 -0
- package/dist/message-distribution.d.ts.map +1 -0
- package/dist/message-distribution.js +35 -0
- package/dist/message-distribution.js.map +1 -0
- package/dist/tool-access.d.ts +16 -0
- package/dist/tool-access.d.ts.map +1 -0
- package/dist/tool-access.js +30 -0
- package/dist/tool-access.js.map +1 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +77 -0
- package/dist/tools.js.map +1 -0
- package/dist/transport.d.ts +21 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +36 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +165 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +12 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +94 -0
- package/dist/validation.js.map +1 -0
- package/docs/API_REFERENCE.md +116 -0
- package/docs/CONFORMANCE.md +96 -0
- package/docs/GITHUB_PAGES.md +54 -0
- package/docs/NPM_RELEASE.md +107 -0
- package/docs/SDK_GUIDE.md +439 -0
- package/examples/calendar.ts +105 -0
- package/package.json +60 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# GB/Z 185 Conformance Verification
|
|
2
|
+
|
|
3
|
+
This document verifies `gbz185-sdk` against the seven GB/Z 185-2026 agent interconnection documents supplied in this workspace.
|
|
4
|
+
|
|
5
|
+
The verification scope is SDK-level conformance: types, validation helpers, runtime surfaces, lifecycle flows, and transport extension points. The GB/Z 185 files are guidance documents, so some items are necessarily implemented as adapter interfaces rather than fixed code.
|
|
6
|
+
|
|
7
|
+
## Result
|
|
8
|
+
|
|
9
|
+
- Functional domains from GB/Z 185.1: covered.
|
|
10
|
+
- FRAI-01 through FRAI-10: covered by exported coverage constants and runtime/client surfaces.
|
|
11
|
+
- GB/Z 185.2 identity-code structure and validation: covered.
|
|
12
|
+
- GB/Z 185.3 identity, credential, and authentication lifecycle: covered by reference runtime plus production adapter interfaces.
|
|
13
|
+
- GB/Z 185.4 description lifecycle: covered.
|
|
14
|
+
- GB/Z 185.5 discovery service and preset discovery: covered.
|
|
15
|
+
- GB/Z 185.6 interaction models and group message distribution: covered.
|
|
16
|
+
- GB/Z 185.7 tool service and tool access: covered.
|
|
17
|
+
|
|
18
|
+
Items marked as extension points are not missing SDK functions. They are areas where the standard references governance, UI, CA, network, scheduler, or security infrastructure that must be supplied by the application environment.
|
|
19
|
+
|
|
20
|
+
## Coverage Matrix
|
|
21
|
+
|
|
22
|
+
| Standard | Clause | Topic | Status | SDK Surface |
|
|
23
|
+
| --- | --- | --- | --- | --- |
|
|
24
|
+
| GB/Z 185.1 | 5 | Concept model domains | Covered | `createAgentInterconnectRuntime`, `AgentInterconnectRuntime`, `GBZ185_FUNCTIONS` |
|
|
25
|
+
| GB/Z 185.1 | 6.2 | Functional reference architecture function set | Covered | `GBZ185_FUNCTIONS` |
|
|
26
|
+
| GB/Z 185.1 | 6.3 | FRAI-01 through FRAI-10 | Covered | `GBZ185_FRAI_INTERFACES` |
|
|
27
|
+
| GB/Z 185.2 | 5.1-5.6 | Identity code OID/version/provider/requester/serial structure | Covered | `formatIdentityCode`, `parseIdentityCode`, `validateIdentityCode` |
|
|
28
|
+
| GB/Z 185.2 | 6 | Identity-code allocation and management | Covered by reference runtime | `IdentityRegistryRuntime`, `AgentIdentityMaintenance` |
|
|
29
|
+
| GB/Z 185.2 | Appendix B | International identity-code governance | Extension point | `IdentityAccountStore`, `IdentityRegistryRuntime` |
|
|
30
|
+
| GB/Z 185.3 | 5 | Identity-management framework | Covered | `IdentityRegistryRuntime`, `CredentialIssuer`, `CredentialVerifier`, `InterconnectionAuthorizationRuntime` |
|
|
31
|
+
| GB/Z 185.3 | 6 | Registration and evidence verification | Covered by reference runtime | `IdentityRegistryRuntime.register`, `RegisterIdentityInput.evidence` |
|
|
32
|
+
| GB/Z 185.3 | 7 | Account update/lock/unlock/revoke/audit | Covered by reference runtime | `IdentityRegistryRuntime`, `IdentityAuditEvent` |
|
|
33
|
+
| GB/Z 185.3 | 8 | Credential issue/update/lock/unlock/revoke/status | Covered by reference runtime | `CredentialIssuer`, `CredentialStatusStore` |
|
|
34
|
+
| GB/Z 185.3 | 9 | Presentation, verification, assertion, authorization | Covered by reference runtime | `createProcessCredentialPackage`, `CredentialVerifier`, `InterconnectionAuthorizationRuntime` |
|
|
35
|
+
| GB/Z 185.3 | 9.2 | National CA roots, algorithms, immutable audit | Extension point | `CertificateChainVerifier`, `CredentialIssuer`, `CredentialVerifier` |
|
|
36
|
+
| GB/Z 185.4 | 5 | Agent description and skill attributes | Covered | `AgentDescription`, `SkillDescription`, validation helpers |
|
|
37
|
+
| GB/Z 185.4 | 6-8 | Register/review/certificate/publish/change/unpublish/revoke | Covered by reference runtime | `AgentDescriptionRegistry`, `AgentDescriptionMaintenance` |
|
|
38
|
+
| GB/Z 185.5 | 5-6.1 | Discovery service flow | Covered by reference runtime | `DiscoveryService`, `AgentInterconnectClient.discover` |
|
|
39
|
+
| GB/Z 185.5 | 6.2 | Preset/cache/user/well-known discovery | Covered by reference runtime | `PresetDiscoverySource`, `DiscoveryService` |
|
|
40
|
+
| GB/Z 185.5 | 6.1 | API/GUI/LUI query interface | Extension point | `JsonTransport`, `HttpJsonTransport`, `AgentInterconnectClient` |
|
|
41
|
+
| GB/Z 185.6 | 5-6 | Point-to-point/group/hybrid modes | Covered by reference runtime | `InteractionRuntime`, `AgentInteractionMode` |
|
|
42
|
+
| GB/Z 185.6 | 7 | Data/message/task/session models | Covered | `DataItem`, `Message`, `Task`, `Session` |
|
|
43
|
+
| GB/Z 185.6 | 8 | Point-to-point and group message flows | Covered by reference runtime | `InteractionRuntime`, `MessageDistributionRuntime` |
|
|
44
|
+
| GB/Z 185.6 | Appendix A-B | Streaming/notification/collaboration patterns | Extension point | `JsonTransport`, `InteractionRuntime`, `MessageDistributionRuntime` |
|
|
45
|
+
| GB/Z 185.7 | 4 | Tool architecture | Covered | `ToolAccessRuntime`, `ToolRuntime` |
|
|
46
|
+
| GB/Z 185.7 | 5 | Tool list/update/invocation loop | Covered by reference runtime | `ToolAccessRuntime`, `ToolRuntime` |
|
|
47
|
+
| GB/Z 185.7 | 6 | Tool data formats | Covered | `ToolDescriptor`, `ToolRequestData`, `ToolSyncData`, `ToolUpdateData`, `ToolInvokeRequest`, `ToolInvokeResult` |
|
|
48
|
+
|
|
49
|
+
The same matrix is exported as `GBZ185_CONFORMANCE_MATRIX` for automated checks.
|
|
50
|
+
|
|
51
|
+
## Automated Verification
|
|
52
|
+
|
|
53
|
+
The package test suite verifies:
|
|
54
|
+
|
|
55
|
+
- identity code parse/format/validation and malformed code rejection;
|
|
56
|
+
- description required fields and skill fields;
|
|
57
|
+
- discovery service, preset filtering behavior, undiscoverable filtering, empty-result handling;
|
|
58
|
+
- description review, publication certificate, publish, unpublish, and revoke;
|
|
59
|
+
- point-to-point and group interaction flows;
|
|
60
|
+
- message distribution receipts;
|
|
61
|
+
- tool list acquisition, updates, success, missing tool, and repeated invocation;
|
|
62
|
+
- credential success, expiry, lock, audience mismatch, and tamper rejection;
|
|
63
|
+
- interconnection authorization facade;
|
|
64
|
+
- identity revocation linked to credential revocation;
|
|
65
|
+
- GB/Z 185.1 function-domain and FRAI interface coverage;
|
|
66
|
+
- conformance matrix coverage for all seven standard parts.
|
|
67
|
+
|
|
68
|
+
Run:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm install
|
|
72
|
+
pnpm typecheck
|
|
73
|
+
pnpm test
|
|
74
|
+
pnpm build
|
|
75
|
+
pnpm pack --pack-destination /tmp
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Current verified package name:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
gbz185-sdk@0.1.0
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Explicit Adapter Boundaries
|
|
85
|
+
|
|
86
|
+
The SDK deliberately does not hard-code the following because the standards do not define concrete implementation details or because the responsibility belongs to external governance infrastructure:
|
|
87
|
+
|
|
88
|
+
- regulator-approved identity registration service governance;
|
|
89
|
+
- international identity-code approval processes;
|
|
90
|
+
- production CA, national algorithm suite, key custody, and certificate-status service;
|
|
91
|
+
- immutable audit-log storage;
|
|
92
|
+
- legal/risk review policy for description registration and publication;
|
|
93
|
+
- GUI/LUI discovery interfaces;
|
|
94
|
+
- fixed REST paths, WebSocket frames, MCP methods, message brokers, schedulers, or callback URLs.
|
|
95
|
+
|
|
96
|
+
Each of those areas has an exported interface or transport boundary so production systems can provide the required implementation without changing the SDK object model.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# GitHub Pages Deployment
|
|
2
|
+
|
|
3
|
+
This repository is configured to publish the static documentation site from the `site/` directory with GitHub Actions.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- `.github/workflows/pages.yml`: GitHub Pages workflow.
|
|
8
|
+
- `site/index.html`: documentation home page.
|
|
9
|
+
- `site/api.html`: API overview.
|
|
10
|
+
- `site/conformance.html`: GB/Z 185 conformance page.
|
|
11
|
+
- `site/assets/styles.css`: shared styles.
|
|
12
|
+
|
|
13
|
+
## Deployment
|
|
14
|
+
|
|
15
|
+
On every push to `main`, GitHub Actions uploads the `site/` directory and deploys it to GitHub Pages.
|
|
16
|
+
|
|
17
|
+
Canonical URL for this repository:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
https://blogs.idevlab.dev/gbz185-sdk/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Default GitHub Pages URL:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
https://ichendev.github.io/gbz185-sdk/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The default GitHub Pages URL redirects to the account-level custom domain above.
|
|
30
|
+
|
|
31
|
+
Manual redeploy:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
gh workflow run "Deploy GitHub Pages"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Check deployment status:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
gh run list --workflow "Deploy GitHub Pages"
|
|
41
|
+
gh run watch
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Local Preview
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python3 -m http.server 4173 --directory site
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Open:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
http://localhost:4173/
|
|
54
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# npm Release Checklist
|
|
2
|
+
|
|
3
|
+
This package is prepared for the public npm package name:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
gbz185-sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
As of 2026-06-26, `npm view gbz185-sdk` returns `404 Not Found`, so the name is available unless someone publishes it first.
|
|
10
|
+
|
|
11
|
+
## 1. Account And Registry
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm whoami
|
|
15
|
+
npm config get registry
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Expected registry:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
https://registry.npmjs.org/
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If `npm whoami` returns `E401`, login first:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If the account has 2FA enabled, npm will ask for an OTP during publish.
|
|
31
|
+
|
|
32
|
+
## 2. Version Check
|
|
33
|
+
|
|
34
|
+
For the first release, `package.json` is set to `0.1.0`.
|
|
35
|
+
|
|
36
|
+
Before later releases:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm view gbz185-sdk version dist-tags
|
|
40
|
+
pnpm version patch
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Use `patch`, `minor`, or `major` according to the public API change.
|
|
44
|
+
|
|
45
|
+
## 3. Local Release Gate
|
|
46
|
+
|
|
47
|
+
Run the same checks that `prepublishOnly` runs:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm install --frozen-lockfile
|
|
51
|
+
pnpm typecheck
|
|
52
|
+
pnpm test
|
|
53
|
+
pnpm build
|
|
54
|
+
pnpm example:calendar
|
|
55
|
+
pnpm pack:check
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The package should include `dist`, `docs`, `examples`, `README.md`, `LICENSE`, `CHANGELOG.md`, and `package.json`. It should not include `src`, `test`, `site`, `node_modules`, or local tarballs.
|
|
59
|
+
|
|
60
|
+
## 4. Publish
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm publish --access public
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`package.json` already includes:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The explicit `--access public` flag is still recommended for the first publish.
|
|
77
|
+
|
|
78
|
+
## 5. Post-Publish Smoke Test
|
|
79
|
+
|
|
80
|
+
After npm confirms publication:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm view gbz185-sdk version dist-tags
|
|
84
|
+
|
|
85
|
+
mkdir -p /tmp/gbz185-sdk-npm-smoke
|
|
86
|
+
cd /tmp/gbz185-sdk-npm-smoke
|
|
87
|
+
npm init -y
|
|
88
|
+
npm install gbz185-sdk
|
|
89
|
+
node --input-type=module -e "import { formatIdentityCode, validateIdentityCode } from 'gbz185-sdk'; const id = formatIdentityCode({ registrationServiceProvider: 'A1', registrationRequester: 'REQ001', ontologySerial: 'CALENDAR', instanceSerial: '1' }); console.log(id, validateIdentityCode(id));"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Expected output includes:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
1.2.156.3088.1.A1.REQ001.CALENDAR.1 true
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 6. Git Tag
|
|
99
|
+
|
|
100
|
+
After a successful publish:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
git tag v0.1.0
|
|
104
|
+
git push origin v0.1.0
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
For later versions, tag the exact published version.
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
# GB/Z 185 SDK Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how the SDK maps GB/Z 185-2026 into TypeScript APIs and how to use the reference runtime.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install gbz185-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package is ESM-only and supports Node.js `>=20`. It also works with `pnpm add gbz185-sdk` and `yarn add gbz185-sdk`.
|
|
12
|
+
|
|
13
|
+
## 1. Runtime Shape
|
|
14
|
+
|
|
15
|
+
The SDK is organized around the seven GB/Z 185 parts:
|
|
16
|
+
|
|
17
|
+
| GB/Z 185 Part | SDK Surface |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| 185.1 General architecture | `createAgentInterconnectRuntime()` wires the identity, description, discovery, interaction, and tool domains. |
|
|
20
|
+
| 185.2 Identity code | `formatIdentityCode`, `parseIdentityCode`, `validateIdentityCode`. |
|
|
21
|
+
| 185.3 Identity management | `IdentityRegistryRuntime`, `CredentialIssuer`, `CredentialVerifier`, process credential packages, authentication assertions. |
|
|
22
|
+
| 185.4 Agent description | `AgentDescription`, `SkillDescription`, `AgentDescriptionRegistry`. |
|
|
23
|
+
| 185.5 Agent discovery | `DiscoveryService`, `DiscoveryQuery`, `DiscoveryResult`, preset discovery sources. |
|
|
24
|
+
| 185.6 Agent interaction | `Session`, `Task`, `Message`, `DataItem`, `InteractionRuntime`. |
|
|
25
|
+
| 185.7 Tool invocation | `ToolDescriptor`, `ToolRuntime`, tool list sync, tool updates, tool invocation results. |
|
|
26
|
+
|
|
27
|
+
The default runtime is in-memory and in-process. It is intended for local development, tests, examples, and protocol experiments.
|
|
28
|
+
|
|
29
|
+
## 1.1 Complete Function Coverage
|
|
30
|
+
|
|
31
|
+
GB/Z 185.1 defines function domains in the agent domain, management service domain, interconnection service domain, and resource access domain. The SDK exposes each function domain as a runtime, facade, or interface.
|
|
32
|
+
|
|
33
|
+
| Domain | Standard Function | SDK Surface |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| Agent domain | Agent identity maintenance | `AgentIdentityMaintenance` |
|
|
36
|
+
| Agent domain | Agent description maintenance | `AgentDescriptionMaintenance` |
|
|
37
|
+
| Agent domain | Agent interconnection authorization | `InterconnectionAuthorizationRuntime` |
|
|
38
|
+
| Agent domain | Agent interaction | `InteractionRuntime` |
|
|
39
|
+
| Agent domain | Tool access | `ToolAccessRuntime` |
|
|
40
|
+
| Management service domain | Agent identity management | `IdentityRegistryRuntime` |
|
|
41
|
+
| Management service domain | Agent credential management | `CredentialIssuer` / `DevelopmentCredentialIssuer` |
|
|
42
|
+
| Management service domain | Agent identity authentication | `CredentialVerifier` / `DevelopmentCredentialVerifier` |
|
|
43
|
+
| Interconnection service domain | Agent description management | `AgentDescriptionRegistry` |
|
|
44
|
+
| Interconnection service domain | Agent discovery | `DiscoveryService` |
|
|
45
|
+
| Interconnection service domain | Message distribution | `MessageDistributionRuntime` |
|
|
46
|
+
| Resource access domain | Tool service | `ToolRuntime` |
|
|
47
|
+
|
|
48
|
+
The SDK also exports `GBZ185_FUNCTIONS` and `GBZ185_FRAI_INTERFACES` for machine-readable coverage checks. The FRAI constants cover `FRAI-01` through `FRAI-10`.
|
|
49
|
+
|
|
50
|
+
For a clause-level verification matrix, see `docs/CONFORMANCE.md` or import `GBZ185_CONFORMANCE_MATRIX`.
|
|
51
|
+
|
|
52
|
+
## 2. Identity Codes
|
|
53
|
+
|
|
54
|
+
GB/Z 185.2 uses an OID-style identity code. This SDK fixes the standard prefix and current version:
|
|
55
|
+
|
|
56
|
+
- OID prefix: `1.2.156.3088`
|
|
57
|
+
- Version: `1`
|
|
58
|
+
- Registration service provider: up to 6 base36 characters
|
|
59
|
+
- Registration requester: up to 6 base36 characters
|
|
60
|
+
- Ontology serial: up to 9 base36 characters
|
|
61
|
+
- Instance serial: up to 9 base36 characters
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { formatIdentityCode, parseIdentityCode, validateIdentityCode } from "gbz185-sdk";
|
|
65
|
+
|
|
66
|
+
const agentId = formatIdentityCode({
|
|
67
|
+
registrationServiceProvider: "A1",
|
|
68
|
+
registrationRequester: "REQ001",
|
|
69
|
+
ontologySerial: "CALENDAR",
|
|
70
|
+
instanceSerial: "1"
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
console.log(agentId);
|
|
74
|
+
// 1.2.156.3088.1.A1.REQ001.CALENDAR.1
|
|
75
|
+
|
|
76
|
+
console.log(validateIdentityCode(agentId));
|
|
77
|
+
console.log(parseIdentityCode(agentId));
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 3. Register And Publish An Agent
|
|
81
|
+
|
|
82
|
+
Use `createAgentInterconnectRuntime()` when you want all in-memory services connected through the default `InProcessJsonTransport`.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { createAgentInterconnectRuntime, type AgentDescription } from "gbz185-sdk";
|
|
86
|
+
|
|
87
|
+
const runtime = createAgentInterconnectRuntime();
|
|
88
|
+
|
|
89
|
+
const registration = await runtime.client.registerIdentity({
|
|
90
|
+
delegatorId: "example-org",
|
|
91
|
+
subject: "Calendar Agent",
|
|
92
|
+
registrationServiceProvider: "A1",
|
|
93
|
+
registrationRequester: "REQ001",
|
|
94
|
+
ontologySerial: "CALENDAR",
|
|
95
|
+
instanceSerial: "1",
|
|
96
|
+
issueCredential: true,
|
|
97
|
+
credentialAudience: ["requester-agent"],
|
|
98
|
+
credentialScope: ["agent:interact", "tool:invoke"]
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const description: AgentDescription = {
|
|
102
|
+
agentId: registration.account.id,
|
|
103
|
+
name: "Calendar Agent",
|
|
104
|
+
version: "1.0.0",
|
|
105
|
+
description: "Creates calendar events",
|
|
106
|
+
provider: "Example Org",
|
|
107
|
+
capabilities: { asyncMessages: true },
|
|
108
|
+
defaultInputTypes: ["text", "json"],
|
|
109
|
+
defaultOutputTypes: ["json"],
|
|
110
|
+
skills: [
|
|
111
|
+
{
|
|
112
|
+
skillId: "schedule.add",
|
|
113
|
+
skillName: "add_schedule",
|
|
114
|
+
skillDescription: "Add one calendar schedule item",
|
|
115
|
+
tags: ["calendar", "schedule"],
|
|
116
|
+
inputTypes: ["text", "json"],
|
|
117
|
+
outputTypes: ["json"]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
await runtime.client.registerDescription(description);
|
|
123
|
+
await runtime.client.publishDescription(description.agentId);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The full description lifecycle also includes review, publication certificate issuance, unpublish, and revoke:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
await runtime.client.reviewDescription(description.agentId, {
|
|
130
|
+
reviewerId: "description-manager",
|
|
131
|
+
approved: true,
|
|
132
|
+
riskLevel: "low"
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
await runtime.client.issuePublicationCertificate(description.agentId, {
|
|
136
|
+
issuer: "description-manager",
|
|
137
|
+
publicKeyDigest: "sha256:..."
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await runtime.client.publishDescriptionWithInfo(description.agentId, {
|
|
141
|
+
regions: ["CN"],
|
|
142
|
+
openBeta: false,
|
|
143
|
+
paid: false,
|
|
144
|
+
permissionRequirements: ["calendar.write"]
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await runtime.client.unpublishDescription(description.agentId);
|
|
148
|
+
await runtime.client.revokeDescription(description.agentId, "retired");
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 4. Discovery
|
|
152
|
+
|
|
153
|
+
Discovery searches published descriptions and optional preset sources. By default, descriptions marked `discoverable: false` are filtered out.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const results = await runtime.client.discover({
|
|
157
|
+
text: "calendar schedule",
|
|
158
|
+
requiredSkills: ["schedule.add"],
|
|
159
|
+
inputTypes: ["text"],
|
|
160
|
+
outputTypes: ["json"],
|
|
161
|
+
requireAvailable: true
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const target = results[0]?.description;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`DiscoveryQuery` supports:
|
|
168
|
+
|
|
169
|
+
- `text`
|
|
170
|
+
- `agentId`
|
|
171
|
+
- `name`
|
|
172
|
+
- `requiredSkills`
|
|
173
|
+
- `tags`
|
|
174
|
+
- `inputTypes`
|
|
175
|
+
- `outputTypes`
|
|
176
|
+
- `includeUndiscoverable`
|
|
177
|
+
- `requireAvailable`
|
|
178
|
+
- `limit`
|
|
179
|
+
|
|
180
|
+
## 5. Interaction
|
|
181
|
+
|
|
182
|
+
GB/Z 185.6 is represented as:
|
|
183
|
+
|
|
184
|
+
- `Session`: a multi-agent interaction process
|
|
185
|
+
- `Task`: a work unit inside a session
|
|
186
|
+
- `Message`: an exchange unit
|
|
187
|
+
- `DataItem`: the message payload unit
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const session = await runtime.client.createSession({
|
|
191
|
+
mode: "point_to_point",
|
|
192
|
+
sender: { agentId: "requester-agent-id" },
|
|
193
|
+
receivers: [{ agentId: target.agentId, mode: "point_to_point" }]
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const task = await runtime.client.submitTask({ sessionId: session.id });
|
|
197
|
+
|
|
198
|
+
await runtime.client.sendMessage({
|
|
199
|
+
senderRole: "service",
|
|
200
|
+
senderId: target.agentId,
|
|
201
|
+
sessionId: session.id,
|
|
202
|
+
taskId: task.id,
|
|
203
|
+
artifact: "work_result",
|
|
204
|
+
final: true,
|
|
205
|
+
lastChunk: true,
|
|
206
|
+
dataItems: [
|
|
207
|
+
{
|
|
208
|
+
type: "application/json",
|
|
209
|
+
metadata: {},
|
|
210
|
+
payload: { ok: true }
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Supported interaction modes are:
|
|
217
|
+
|
|
218
|
+
- `point_to_point`
|
|
219
|
+
- `group`
|
|
220
|
+
- `hybrid`
|
|
221
|
+
|
|
222
|
+
For group mode, use `MessageDistributionRuntime` or the client `distributeMessage` helper. The distribution service records delivery receipts and writes the source message into the interaction runtime.
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
const receipts = await runtime.client.distributeMessage({
|
|
226
|
+
senderRole: "requester",
|
|
227
|
+
senderId: "requester-agent-id",
|
|
228
|
+
sessionId: session.id,
|
|
229
|
+
dataItems: [{ type: "text/plain", metadata: {}, payload: "hello group" }]
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 6. Tool Invocation
|
|
234
|
+
|
|
235
|
+
Register tools with `ToolRuntime`, then invoke them through the client.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
await runtime.toolRuntime.registerTool(
|
|
239
|
+
{
|
|
240
|
+
toolId: "calendar.add",
|
|
241
|
+
toolName: "add_schedule",
|
|
242
|
+
toolDescription: "Add one calendar event",
|
|
243
|
+
toolVersion: "1.0.0",
|
|
244
|
+
toolInputParam: { date: "string", time: "string", event: "string" },
|
|
245
|
+
toolOutputParam: { eventId: "string", accepted: "boolean" }
|
|
246
|
+
},
|
|
247
|
+
(input) => ({
|
|
248
|
+
eventId: `evt-${input.date}-${input.time}`,
|
|
249
|
+
accepted: true
|
|
250
|
+
})
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
const toolResult = await runtime.client.invokeTools({
|
|
254
|
+
sessionId: session.id,
|
|
255
|
+
toolInvokeList: [
|
|
256
|
+
{
|
|
257
|
+
toolId: "calendar.add",
|
|
258
|
+
toolVersion: "1.0.0",
|
|
259
|
+
toolInputParam: {
|
|
260
|
+
date: "2026-06-26",
|
|
261
|
+
time: "10:00",
|
|
262
|
+
event: "GB/Z 185 SDK review"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Tool failures are returned as result items instead of throwing for the whole batch. For example, a missing tool returns `statusCode: "TOOL_NOT_FOUND"` and `ok: false`.
|
|
270
|
+
|
|
271
|
+
The agent-side tool-access facade wraps the resource-side tool service:
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
const tools = await runtime.toolAccess.getToolList();
|
|
275
|
+
const updates = await runtime.toolAccess.syncToolUpdates();
|
|
276
|
+
const rounds = await runtime.toolAccess.invokeUntilComplete({
|
|
277
|
+
initialRequest: {
|
|
278
|
+
sessionId: session.id,
|
|
279
|
+
toolInvokeList: [
|
|
280
|
+
{
|
|
281
|
+
toolId: "calendar.add",
|
|
282
|
+
toolVersion: "1.0.0",
|
|
283
|
+
toolInputParam: { date: "2026-06-26", time: "10:00", event: "review" }
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
isComplete: (result) => result.toolResultList.every((item) => item.ok),
|
|
288
|
+
nextRequest: (result) => ({
|
|
289
|
+
sessionId: session.id,
|
|
290
|
+
toolInvokeList: []
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## 7. Credential Verification
|
|
296
|
+
|
|
297
|
+
The credential layer is X.509-first by interface:
|
|
298
|
+
|
|
299
|
+
- `CertificateChainVerifier`
|
|
300
|
+
- `CredentialStatusStore`
|
|
301
|
+
- `CredentialIssuer`
|
|
302
|
+
- `CredentialVerifier`
|
|
303
|
+
|
|
304
|
+
The bundled `DevelopmentCredentialIssuer` uses Node.js `crypto` with Ed25519 keys so local flows can run without an external CA. It can optionally verify a supplied PEM certificate through `NodeX509CertificateChainVerifier`, but it is not a production CA implementation.
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
import {
|
|
308
|
+
DevelopmentCredentialIssuer,
|
|
309
|
+
DevelopmentCredentialVerifier,
|
|
310
|
+
InMemoryCredentialRepository,
|
|
311
|
+
InMemoryCredentialStatusStore,
|
|
312
|
+
createProcessCredentialPackage
|
|
313
|
+
} from "gbz185-sdk";
|
|
314
|
+
|
|
315
|
+
const repository = new InMemoryCredentialRepository();
|
|
316
|
+
const statusStore = new InMemoryCredentialStatusStore();
|
|
317
|
+
const issuer = new DevelopmentCredentialIssuer(repository, statusStore);
|
|
318
|
+
const verifier = new DevelopmentCredentialVerifier(statusStore);
|
|
319
|
+
|
|
320
|
+
const issued = await issuer.issueCredential({
|
|
321
|
+
agentId: "agent-id",
|
|
322
|
+
subject: "Requester Agent",
|
|
323
|
+
audience: ["service-agent"],
|
|
324
|
+
scope: ["agent:interact"]
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const presentation = createProcessCredentialPackage({
|
|
328
|
+
credential: issued.credential,
|
|
329
|
+
privateKeyPem: issued.privateKeyPem,
|
|
330
|
+
audience: "service-agent",
|
|
331
|
+
scope: ["agent:interact"],
|
|
332
|
+
payload: { action: "connect" }
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const assertion = await verifier.verifyPresentation({
|
|
336
|
+
package: presentation,
|
|
337
|
+
expectedAudience: "service-agent",
|
|
338
|
+
requiredScope: ["agent:interact"]
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Agent interconnection authorization is available as a higher-level facade:
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
const auth = runtime.interconnectionAuthorization;
|
|
346
|
+
const presentation = auth.createPresentation({
|
|
347
|
+
credential: issued.credential,
|
|
348
|
+
privateKeyPem: issued.privateKeyPem,
|
|
349
|
+
audience: "service-agent",
|
|
350
|
+
scope: ["agent:interact"]
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
const decision = await auth.authenticatePeer(presentation, {
|
|
354
|
+
expectedAudience: "service-agent",
|
|
355
|
+
requiredScope: ["agent:interact"]
|
|
356
|
+
});
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Identity account lock/unlock/revoke operations are linked to associated credential states in the reference runtime. Revoking an identity account also revokes credentials issued through that account.
|
|
360
|
+
|
|
361
|
+
For production, replace the development issuer/verifier/status store with implementations backed by your CA, key custody, certificate status service, audit log, and persistence layer.
|
|
362
|
+
|
|
363
|
+
## 8. Transport
|
|
364
|
+
|
|
365
|
+
The SDK does not define REST paths or WebSocket frames. Every client method delegates to:
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
interface JsonTransport {
|
|
369
|
+
request<TRequest, TResponse>(operation: string, payload: TRequest): Promise<TResponse>;
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Bundled transports:
|
|
374
|
+
|
|
375
|
+
- `InProcessJsonTransport`: local runtime and tests.
|
|
376
|
+
- `HttpJsonTransport`: POSTs `{ operation, payload }` to a configured endpoint.
|
|
377
|
+
|
|
378
|
+
Operation names used by `createAgentInterconnectRuntime()`:
|
|
379
|
+
|
|
380
|
+
- `identity.register`
|
|
381
|
+
- `identity.get`
|
|
382
|
+
- `identity.issueCredential`
|
|
383
|
+
- `identity.lock`
|
|
384
|
+
- `identity.unlock`
|
|
385
|
+
- `identity.revoke`
|
|
386
|
+
- `description.register`
|
|
387
|
+
- `description.review`
|
|
388
|
+
- `description.issuePublicationCertificate`
|
|
389
|
+
- `description.publish`
|
|
390
|
+
- `description.unpublish`
|
|
391
|
+
- `description.revoke`
|
|
392
|
+
- `discovery.discover`
|
|
393
|
+
- `interaction.createSession`
|
|
394
|
+
- `interaction.submitTask`
|
|
395
|
+
- `interaction.sendMessage`
|
|
396
|
+
- `interaction.distributeMessage`
|
|
397
|
+
- `tool.list`
|
|
398
|
+
- `tool.updates`
|
|
399
|
+
- `tool.invoke`
|
|
400
|
+
|
|
401
|
+
## 9. Local Verification
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
pnpm install
|
|
405
|
+
pnpm typecheck
|
|
406
|
+
pnpm test
|
|
407
|
+
pnpm build
|
|
408
|
+
pnpm example:calendar
|
|
409
|
+
pnpm pack --pack-destination /tmp
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
The test suite covers:
|
|
413
|
+
|
|
414
|
+
- identity code parse/format/validation
|
|
415
|
+
- description validation
|
|
416
|
+
- discovery filtering and matching
|
|
417
|
+
- session/task/message flows
|
|
418
|
+
- tool list, update, success, and missing-tool failures
|
|
419
|
+
- credential success, expiry, lock, audience mismatch, and tamper rejection
|
|
420
|
+
- full smoke flow: register -> publish -> discover -> session -> tool invocation -> final message
|
|
421
|
+
- full GB/Z 185.1 function-domain coverage constants and FRAI-01 through FRAI-10
|
|
422
|
+
- description review/publication certificate/unpublish/revoke lifecycle
|
|
423
|
+
- group-mode message distribution
|
|
424
|
+
- tool-access facade and iterative invocation
|
|
425
|
+
- identity revocation linked to credential revocation
|
|
426
|
+
|
|
427
|
+
## 10. Boundaries
|
|
428
|
+
|
|
429
|
+
This SDK is a reference implementation and developer toolkit. It intentionally does not decide:
|
|
430
|
+
|
|
431
|
+
- production CA policy
|
|
432
|
+
- national cryptographic algorithm suite
|
|
433
|
+
- HTTP route shape
|
|
434
|
+
- WebSocket event shape
|
|
435
|
+
- MCP adapter semantics
|
|
436
|
+
- database schema
|
|
437
|
+
- distributed message broker behavior
|
|
438
|
+
|
|
439
|
+
Those should be added as application-specific adapters on top of the stable TypeScript interfaces.
|