@m1a0rz/agent-identity 0.1.2
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/README-cn.md +223 -0
- package/README.md +223 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +306 -0
- package/dist/src/actions/identity-actions.d.ts +142 -0
- package/dist/src/actions/identity-actions.d.ts.map +1 -0
- package/dist/src/actions/identity-actions.js +429 -0
- package/dist/src/commands/identity-commands.d.ts +33 -0
- package/dist/src/commands/identity-commands.d.ts.map +1 -0
- package/dist/src/commands/identity-commands.js +572 -0
- package/dist/src/hooks/after-tool-call.d.ts +22 -0
- package/dist/src/hooks/after-tool-call.d.ts.map +1 -0
- package/dist/src/hooks/after-tool-call.js +35 -0
- package/dist/src/hooks/before-agent-start.d.ts +30 -0
- package/dist/src/hooks/before-agent-start.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start.js +93 -0
- package/dist/src/hooks/before-tool-call.d.ts +38 -0
- package/dist/src/hooks/before-tool-call.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call.js +138 -0
- package/dist/src/risk/classify-risk.d.ts +24 -0
- package/dist/src/risk/classify-risk.d.ts.map +1 -0
- package/dist/src/risk/classify-risk.js +61 -0
- package/dist/src/risk/diagnose-risk.d.ts +21 -0
- package/dist/src/risk/diagnose-risk.d.ts.map +1 -0
- package/dist/src/risk/diagnose-risk.js +37 -0
- package/dist/src/risk/llm-risk-check.d.ts +27 -0
- package/dist/src/risk/llm-risk-check.d.ts.map +1 -0
- package/dist/src/risk/llm-risk-check.js +274 -0
- package/dist/src/risk/low-risk-tools.d.ts +5 -0
- package/dist/src/risk/low-risk-tools.d.ts.map +1 -0
- package/dist/src/risk/low-risk-tools.js +29 -0
- package/dist/src/routes/oidc-login.d.ts +51 -0
- package/dist/src/routes/oidc-login.d.ts.map +1 -0
- package/dist/src/routes/oidc-login.js +153 -0
- package/dist/src/services/identity-client.d.ts +366 -0
- package/dist/src/services/identity-client.d.ts.map +1 -0
- package/dist/src/services/identity-client.js +578 -0
- package/dist/src/services/identity-credentials.d.ts +28 -0
- package/dist/src/services/identity-credentials.d.ts.map +1 -0
- package/dist/src/services/identity-credentials.js +170 -0
- package/dist/src/services/identity-service.d.ts +33 -0
- package/dist/src/services/identity-service.d.ts.map +1 -0
- package/dist/src/services/identity-service.js +53 -0
- package/dist/src/services/oidc-client.d.ts +57 -0
- package/dist/src/services/oidc-client.d.ts.map +1 -0
- package/dist/src/services/oidc-client.js +127 -0
- package/dist/src/services/send-notification-feishu.d.ts +27 -0
- package/dist/src/services/send-notification-feishu.d.ts.map +1 -0
- package/dist/src/services/send-notification-feishu.js +148 -0
- package/dist/src/services/session-refresh.d.ts +16 -0
- package/dist/src/services/session-refresh.d.ts.map +1 -0
- package/dist/src/services/session-refresh.js +38 -0
- package/dist/src/store/credential-env-bindings.d.ts +16 -0
- package/dist/src/store/credential-env-bindings.d.ts.map +1 -0
- package/dist/src/store/credential-env-bindings.js +61 -0
- package/dist/src/store/credential-store.d.ts +31 -0
- package/dist/src/store/credential-store.d.ts.map +1 -0
- package/dist/src/store/credential-store.js +57 -0
- package/dist/src/store/oidc-state-store.d.ts +15 -0
- package/dist/src/store/oidc-state-store.d.ts.map +1 -0
- package/dist/src/store/oidc-state-store.js +32 -0
- package/dist/src/store/session-store.d.ts +21 -0
- package/dist/src/store/session-store.d.ts.map +1 -0
- package/dist/src/store/session-store.js +69 -0
- package/dist/src/store/tip-store.d.ts +21 -0
- package/dist/src/store/tip-store.d.ts.map +1 -0
- package/dist/src/store/tip-store.js +60 -0
- package/dist/src/store/tool-approval-store.d.ts +44 -0
- package/dist/src/store/tool-approval-store.d.ts.map +1 -0
- package/dist/src/store/tool-approval-store.js +147 -0
- package/dist/src/tools/identity-approve-tool.d.ts +24 -0
- package/dist/src/tools/identity-approve-tool.d.ts.map +1 -0
- package/dist/src/tools/identity-approve-tool.js +36 -0
- package/dist/src/tools/identity-config.d.ts +13 -0
- package/dist/src/tools/identity-config.d.ts.map +1 -0
- package/dist/src/tools/identity-config.js +18 -0
- package/dist/src/tools/identity-fetch.d.ts +21 -0
- package/dist/src/tools/identity-fetch.d.ts.map +1 -0
- package/dist/src/tools/identity-fetch.js +63 -0
- package/dist/src/tools/identity-list-credentials.d.ts +15 -0
- package/dist/src/tools/identity-list-credentials.d.ts.map +1 -0
- package/dist/src/tools/identity-list-credentials.js +30 -0
- package/dist/src/tools/identity-list-risk-patterns.d.ts +13 -0
- package/dist/src/tools/identity-list-risk-patterns.d.ts.map +1 -0
- package/dist/src/tools/identity-list-risk-patterns.js +23 -0
- package/dist/src/tools/identity-list-tips.d.ts +13 -0
- package/dist/src/tools/identity-list-tips.d.ts.map +1 -0
- package/dist/src/tools/identity-list-tips.js +21 -0
- package/dist/src/tools/identity-login.d.ts +14 -0
- package/dist/src/tools/identity-login.d.ts.map +1 -0
- package/dist/src/tools/identity-login.js +40 -0
- package/dist/src/tools/identity-logout.d.ts +13 -0
- package/dist/src/tools/identity-logout.d.ts.map +1 -0
- package/dist/src/tools/identity-logout.js +24 -0
- package/dist/src/tools/identity-risk-check.d.ts +29 -0
- package/dist/src/tools/identity-risk-check.d.ts.map +1 -0
- package/dist/src/tools/identity-risk-check.js +54 -0
- package/dist/src/tools/identity-set-binding.d.ts +16 -0
- package/dist/src/tools/identity-set-binding.d.ts.map +1 -0
- package/dist/src/tools/identity-set-binding.js +31 -0
- package/dist/src/tools/identity-status.d.ts +13 -0
- package/dist/src/tools/identity-status.d.ts.map +1 -0
- package/dist/src/tools/identity-status.js +41 -0
- package/dist/src/tools/identity-unset-binding.d.ts +15 -0
- package/dist/src/tools/identity-unset-binding.d.ts.map +1 -0
- package/dist/src/tools/identity-unset-binding.js +25 -0
- package/dist/src/tools/identity-whoami.d.ts +13 -0
- package/dist/src/tools/identity-whoami.d.ts.map +1 -0
- package/dist/src/tools/identity-whoami.js +38 -0
- package/dist/src/types.d.ts +93 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +5 -0
- package/dist/src/utils/approval-channel.d.ts +11 -0
- package/dist/src/utils/approval-channel.d.ts.map +1 -0
- package/dist/src/utils/approval-channel.js +13 -0
- package/dist/src/utils/auth.d.ts +24 -0
- package/dist/src/utils/auth.d.ts.map +1 -0
- package/dist/src/utils/auth.js +44 -0
- package/dist/src/utils/derive-session-key.d.ts +78 -0
- package/dist/src/utils/derive-session-key.d.ts.map +1 -0
- package/dist/src/utils/derive-session-key.js +198 -0
- package/openclaw.plugin.json +162 -0
- package/package.json +33 -0
- package/skills/SKILL.md +230 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "agent-identity",
|
|
3
|
+
"name": "Agent Identity",
|
|
4
|
+
"description": "UserPool (用户池) login, TIP token (工作负载令牌 GetWorkloadAccessTokenForJWT), credential 3LO (凭据托管), session management. Integrates with Volcengine 智能体身份和权限管理平台. Credentials from config, env, or file; STS AssumeRole supported.",
|
|
5
|
+
"skills": ["./skills"],
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"identity": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"description": "Identity API config (service code: id). Alias: cis (deprecated).",
|
|
13
|
+
"properties": {
|
|
14
|
+
"endpoint": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Identity API endpoint, e.g. https://id.cn-beijing.volcengineapi.com"
|
|
17
|
+
},
|
|
18
|
+
"accessKeyId": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Optional. When omitted, loaded from VOLCENGINE_ACCESS_KEY or credentialsFile"
|
|
21
|
+
},
|
|
22
|
+
"secretAccessKey": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Optional. When omitted, loaded from VOLCENGINE_SECRET_KEY or credentialsFile"
|
|
25
|
+
},
|
|
26
|
+
"sessionToken": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Optional STS session token (or VOLCENGINE_SESSION_TOKEN)"
|
|
29
|
+
},
|
|
30
|
+
"credentialsFile": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Path to credential JSON (VeFaaS style). Default: VOLCENGINE_CREDENTIALS_FILE or /var/run/secrets/iam/credential"
|
|
33
|
+
},
|
|
34
|
+
"roleTrn": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Role TRN for STS AssumeRole. When set, workload name is omitted; backend uses roleName."
|
|
37
|
+
},
|
|
38
|
+
"workloadName": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Workload name for TIP. Default: agentId or openclaw-agent. Ignored when roleTrn is set."
|
|
41
|
+
},
|
|
42
|
+
"workloadPoolName": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"default": "default"
|
|
45
|
+
},
|
|
46
|
+
"audience": {
|
|
47
|
+
"type": "array",
|
|
48
|
+
"items": { "type": "string" },
|
|
49
|
+
"description": "Audience for the TIP token"
|
|
50
|
+
},
|
|
51
|
+
"durationSeconds": {
|
|
52
|
+
"type": "number",
|
|
53
|
+
"default": 3600
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"userpool": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"description": "UserPool OIDC: explicit (discoveryUrl+clientId) or dynamic (userPoolName+clientName)",
|
|
60
|
+
"properties": {
|
|
61
|
+
"discoveryUrl": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"description": "OIDC discovery base (explicit mode)"
|
|
64
|
+
},
|
|
65
|
+
"clientId": { "type": "string" },
|
|
66
|
+
"clientSecret": { "type": "string" },
|
|
67
|
+
"callbackUrl": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "Full callback URL registered with UserPool client"
|
|
70
|
+
},
|
|
71
|
+
"scope": { "type": "string" },
|
|
72
|
+
"userPoolName": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "Dynamic: resolve pool by name (from_veidentity style)"
|
|
75
|
+
},
|
|
76
|
+
"clientName": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "Dynamic: resolve client by name"
|
|
79
|
+
},
|
|
80
|
+
"autoCreate": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": true,
|
|
83
|
+
"description": "Create UserPool/Client when not found (dynamic mode)"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"authz": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"properties": {
|
|
90
|
+
"enable": {
|
|
91
|
+
"type": "boolean",
|
|
92
|
+
"description": "Enable AuthZ (TIP token, CheckPermission, risk approval) for tool calls"
|
|
93
|
+
},
|
|
94
|
+
"namespaceName": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"description": "Namespace for CheckPermission (Cedar policy). Default: default.",
|
|
97
|
+
"default": "default"
|
|
98
|
+
},
|
|
99
|
+
"lowRiskBypass": {
|
|
100
|
+
"type": "boolean",
|
|
101
|
+
"description": "Skip TIP+CheckPermission for built-in low-risk tools",
|
|
102
|
+
"default": true
|
|
103
|
+
},
|
|
104
|
+
"lowRiskTools": {
|
|
105
|
+
"type": "array",
|
|
106
|
+
"items": { "type": "string" },
|
|
107
|
+
"description": "Extra tool names to treat as low-risk"
|
|
108
|
+
},
|
|
109
|
+
"requireRiskApproval": {
|
|
110
|
+
"type": "boolean",
|
|
111
|
+
"description": "Require user approval for high-risk tools after CheckPermission",
|
|
112
|
+
"default": true
|
|
113
|
+
},
|
|
114
|
+
"enableLlmRiskCheck": {
|
|
115
|
+
"type": "boolean",
|
|
116
|
+
"description": "Use LLM to re-evaluate user-provided commands/paths when rules return medium. Risk reason is shown in approval prompts and block messages.",
|
|
117
|
+
"default": false
|
|
118
|
+
},
|
|
119
|
+
"llmRiskCheck": {
|
|
120
|
+
"type": "object",
|
|
121
|
+
"description": "LLM provider config for risk check. Evaluates commands (exec, process) and file paths (write, apply_patch). Reason is passed to approval flow.",
|
|
122
|
+
"properties": {
|
|
123
|
+
"endpoint": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"description": "Base URL: Ollama (http://localhost:11434) or OpenAI-compat (https://api.openai.com/v1)"
|
|
126
|
+
},
|
|
127
|
+
"api": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"enum": ["ollama", "openai-completions"],
|
|
130
|
+
"description": "API style: ollama for /api/generate, openai-completions for /chat/completions",
|
|
131
|
+
"default": "ollama"
|
|
132
|
+
},
|
|
133
|
+
"model": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"description": "Model name (e.g. qwen3:8b, gpt-4o-mini)"
|
|
136
|
+
},
|
|
137
|
+
"apiKey": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"description": "API key for OpenAI-compatible providers (omit for Ollama)"
|
|
140
|
+
},
|
|
141
|
+
"timeoutMs": {
|
|
142
|
+
"type": "number",
|
|
143
|
+
"description": "Timeout in ms",
|
|
144
|
+
"default": 10000
|
|
145
|
+
},
|
|
146
|
+
"cacheTtlMs": {
|
|
147
|
+
"type": "number",
|
|
148
|
+
"description": "Cache TTL in ms for same tool+params. 0 to disable. Default 300000",
|
|
149
|
+
"default": 300000
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"approvalTtlSeconds": {
|
|
154
|
+
"type": "number",
|
|
155
|
+
"description": "Approval TTL in seconds",
|
|
156
|
+
"default": 300
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@m1a0rz/agent-identity",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Agent Identity: UserPool (用户池) login, TIP token (工作负载令牌), credential hosting (凭据托管 OAuth2/API key), optional tool risk approval. Integrates with Volcengine 智能体身份和权限管理平台.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["openclaw", "identity", "volcengine", "userpool", "credential", "TIP", "auth", "agent"],
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@sinclair/typebox": "0.34.48"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.0.0",
|
|
19
|
+
"typescript": "^5.7.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"openclaw": ">=2026.0.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependenciesMeta": {
|
|
25
|
+
"openclaw": {
|
|
26
|
+
"optional": true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"openclaw": {
|
|
30
|
+
"extensions": ["./dist/index.js"]
|
|
31
|
+
},
|
|
32
|
+
"files": ["dist", "README.md", "README-cn.md", "skills/SKILL.md", "openclaw.plugin.json"]
|
|
33
|
+
}
|
package/skills/SKILL.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: identity
|
|
3
|
+
description: |
|
|
4
|
+
UserPool login, TIP token, credential hosting, and tool risk approval. Activate when user needs to check identity (whoami/status), log in, list/add credentials, manage env bindings, or diagnose/approve risky tool calls.
|
|
5
|
+
Also activates for: 用户说登录、查身份、获取凭据、添加/配置API密钥、绑定环境变量、审批工具调用、风险检查.
|
|
6
|
+
metadata:
|
|
7
|
+
{
|
|
8
|
+
"openclaw":
|
|
9
|
+
{
|
|
10
|
+
"emoji": "🔐",
|
|
11
|
+
"skillKey": "identity",
|
|
12
|
+
"requires": { "config": ["plugins.entries.agent-identity.enabled"] },
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Agent Identity
|
|
18
|
+
|
|
19
|
+
Use the agent-identity plugin for UserPool OIDC login (入站授权), TIP token (工作负载访问令牌), credential hosting (出站授权 OAuth2, API key), and optional tool risk approval (权限管控 AuthZ).
|
|
20
|
+
|
|
21
|
+
**Volcengine terminology**: 用户池 (UserPool), 入站授权 (OIDC login), 出站授权 (credential fetch), 工作负载令牌 (TIP), 凭据托管 (credential hosting), 权限管控 (CheckPermission). Docs: [Volcengine 智能体身份和权限管理](https://www.volcengine.com/docs/86848).
|
|
22
|
+
|
|
23
|
+
**Agent flow:** When the user asks to log in, add credentials, check status, bind env, etc., call the corresponding tools directly. Do not suggest slash commands for those. Slash commands below are for user-initiated use (e.g. `/identity approve <id>` when the user must approve in chat; agent must never call `identity_approve_tool`).
|
|
24
|
+
|
|
25
|
+
## Slash commands (user-initiated)
|
|
26
|
+
|
|
27
|
+
| Command | Purpose |
|
|
28
|
+
| ------- | ------- |
|
|
29
|
+
| `/identity` | Show help |
|
|
30
|
+
| `/identity whoami` | Identity brief |
|
|
31
|
+
| `/identity status` | Full status: session, TIP, credentials, bindings |
|
|
32
|
+
| `/identity login` | Log in via OIDC (returns auth URL) |
|
|
33
|
+
| `/identity logout` | Clear session and TIP |
|
|
34
|
+
| `/identity list-credentials` or `/identity list [page]` | List providers and credentials |
|
|
35
|
+
| `/identity list-tips` | List valid TIP tokens |
|
|
36
|
+
| `/identity config` | Show plugin config (redacted) |
|
|
37
|
+
| `/identity fetch <provider> [--flow=...]` | Add credential |
|
|
38
|
+
| `/identity set <provider> <envVar>` | Bind credential to env var |
|
|
39
|
+
| `/identity unset <provider>` | Remove env binding |
|
|
40
|
+
| `/identity risk <command>` | Diagnose risk for a shell command |
|
|
41
|
+
| `/identity risk-patterns` | List built-in risky patterns |
|
|
42
|
+
| `/identity approve <approval_id>` | Approve high-risk tool call (user runs this; agent must not self-approve) |
|
|
43
|
+
| `/identity reject <approval_id>` | Reject high-risk tool call |
|
|
44
|
+
|
|
45
|
+
## Tools Overview
|
|
46
|
+
|
|
47
|
+
| Tool | Params | Purpose |
|
|
48
|
+
| --------------------------- | ---------------------------------------------- | ------------------------------------------ |
|
|
49
|
+
| `identity_whoami` | — | Identity brief: sub, login time, TIP expiry |
|
|
50
|
+
| `identity_status` | — | Full status: session/TIP (issued, expires, chain), credentials, bindings |
|
|
51
|
+
| `identity_login` | — | Start OIDC login or refresh TIP |
|
|
52
|
+
| `identity_logout` | — | Clear session and TIP |
|
|
53
|
+
| `identity_list_credentials` | `page?` | List providers and credentials (paginated) |
|
|
54
|
+
| `identity_list_tips` | — | List valid TIP tokens and bindings |
|
|
55
|
+
| `identity_config` | — | Show plugin config (secrets redacted) |
|
|
56
|
+
| `identity_fetch` | `provider`, `flow?`, `redirectUrl?`, `scopes?` | Add credential |
|
|
57
|
+
| `identity_set_binding` | `provider`, `envVar` | Bind provider → env var for tool injection |
|
|
58
|
+
| `identity_unset_binding` | `provider` | Remove env binding |
|
|
59
|
+
| `identity_approve_tool` | `approval_id` | Approve a high-risk tool call |
|
|
60
|
+
| `identity_risk_check` | `command?`, `toolName?`, `params?` | Diagnose risk for command or tool call |
|
|
61
|
+
| `identity_list_risk_patterns` | — | List built-in risky patterns and paths |
|
|
62
|
+
|
|
63
|
+
## Risk Detection and Approval
|
|
64
|
+
|
|
65
|
+
When `authz.enable` and `authz.requireRiskApproval` are on, the plugin classifies tool calls (e.g. exec, write, apply_patch) by risk. User-provided commands and file paths are evaluated:
|
|
66
|
+
|
|
67
|
+
- **Rule-based**: Destructive patterns (rm -rf, sudo, curl|bash), sensitive paths (/etc, ~/.ssh).
|
|
68
|
+
- **LLM-based** (optional): When rules return "medium", an LLM re-evaluates for context (enable `authz.enableLlmRiskCheck`).
|
|
69
|
+
|
|
70
|
+
High-risk calls require user approval. The approval message and block reason include the LLM risk explanation when available (e.g. "Pipe-to-shell: network fetch piped to shell execution").
|
|
71
|
+
|
|
72
|
+
## Tool Parameters
|
|
73
|
+
|
|
74
|
+
### identity_login
|
|
75
|
+
|
|
76
|
+
Starts OIDC login or refreshes TIP. **Call when:** "login", "登录", "sign in", "我需要先登录". Required before `identity_fetch`. No params.
|
|
77
|
+
|
|
78
|
+
### identity_whoami
|
|
79
|
+
|
|
80
|
+
Brief identity check. **Call when:** "who am I", "查身份", "am I logged in", "当前登录状态"
|
|
81
|
+
|
|
82
|
+
Returns: `sub`, `hasTip`, `loggedIn`, `sessionLoginAt`, `sessionExpiresAt`, `tipIssuedAt`, `tipExpiresAt`, `tipExpiresInSeconds`, `tipChain`. No params.
|
|
83
|
+
|
|
84
|
+
### identity_status
|
|
85
|
+
|
|
86
|
+
Full status including credentials and bindings. **Call when:** "status", "查看完整状态", "我的凭据和绑定", "show my credentials and bindings"
|
|
87
|
+
|
|
88
|
+
Returns: `loggedIn`, `sub`, `hasTip`, `session` (loginAt, expiresAt), `tip` (issuedAt, expiresAt, chain), `credentialProviders`, `bindings`. No params.
|
|
89
|
+
|
|
90
|
+
### identity_list_credentials
|
|
91
|
+
|
|
92
|
+
Lists available credential providers and what the user has stored. **Call this when the user wants to see what they can connect or what credentials they have.**
|
|
93
|
+
|
|
94
|
+
**User prompts:** "有哪些服务可以连接", "what providers are available", "我添加了哪些凭据", "list my credentials", "show available providers"
|
|
95
|
+
|
|
96
|
+
| Param | Type | Required | Description |
|
|
97
|
+
| ------ | ------ | -------- | ------------------------ |
|
|
98
|
+
| `page` | number | No | Page number (default: 1) |
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{ "page": 2 }
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Returns: `providers`, `storedOnly`, `page`, `hasMore`.
|
|
105
|
+
|
|
106
|
+
### identity_fetch
|
|
107
|
+
|
|
108
|
+
Adds a credential for a provider (OAuth2 or API key). **Call this when the user wants to add, get, or configure credentials.**
|
|
109
|
+
|
|
110
|
+
**User prompts that mean "call identity_fetch":**
|
|
111
|
+
|
|
112
|
+
- English: "add/google my Google token", "get credentials for OpenAI", "connect my GitHub", "I need to use Google API", "set up API key for X", "authorize access to Y", "I want to use [provider] but have no key"
|
|
113
|
+
- 中文: "帮我添加/获取 Google 凭据", "配置 OpenAI 的 API key", "连接我的 GitHub", "我要用某某服务但没有密钥", "授权访问某平台", "添加某某的 token", "获取某某的凭证"
|
|
114
|
+
|
|
115
|
+
First ensure user is logged in (`identity_whoami`); if not, use `identity_login`. Then call `identity_fetch` with the provider. Use `identity_list_credentials` to discover available providers.
|
|
116
|
+
|
|
117
|
+
| Param | Type | Required | Description |
|
|
118
|
+
| ------------- | -------- | -------- | --------------------------------------------------------------------------------------- |
|
|
119
|
+
| `provider` | string | Yes | Provider name (e.g. `google`, `openai`) |
|
|
120
|
+
| `flow` | string | No | `oauth2-user` (default for 3LO), `oauth2-m2m`, or `apikey`. Auto-inferred when omitted. |
|
|
121
|
+
| `redirectUrl` | string | No | OAuth redirect URL (when provider requires custom) |
|
|
122
|
+
| `scopes` | string[] | No | OAuth scopes (e.g. `["email", "profile"]`) |
|
|
123
|
+
| `returnValue` | boolean | No | When true and fetch succeeds, include credential `value` in result for same-turn automation. Default false. |
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{ "provider": "google" }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{ "provider": "openai", "flow": "apikey", "returnValue": true }
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Response:**
|
|
134
|
+
|
|
135
|
+
- **OAuth2-user**: `authUrl` (user must open in browser). After authorization, success message sent to chat.
|
|
136
|
+
- **OAuth2-m2m** / **apikey**: `success: true`, `message` (completes immediately). If `returnValue: true`, also includes `value` (credential string) for same-turn use.
|
|
137
|
+
|
|
138
|
+
### identity_set_binding
|
|
139
|
+
|
|
140
|
+
Binds a stored credential to an env var so tools can use it at runtime. **Call this when the user wants tools/agent to have access to a credential.**
|
|
141
|
+
|
|
142
|
+
**User prompts:** "让工具能用我的 Google 凭据", "bind/google my credential for tools", "把 Google token 注入给 agent", "inject my OpenAI key for API calls", "配置某某凭据给工具用"
|
|
143
|
+
|
|
144
|
+
Credential must exist first (`identity_fetch`). Common env vars: `GOOGLE_ACCESS_TOKEN`, `OPENAI_API_KEY`, `GITHUB_TOKEN`, etc.
|
|
145
|
+
|
|
146
|
+
| Param | Type | Required | Description |
|
|
147
|
+
| ---------- | ------ | -------- | ---------------------------------------------------------------------------------------- |
|
|
148
|
+
| `provider` | string | Yes | Provider name (e.g. `google`) |
|
|
149
|
+
| `envVar` | string | Yes | Env var for injection (e.g. `GOOGLE_ACCESS_TOKEN`). Must match `[A-Za-z_][A-Za-z0-9_]*`. |
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{ "provider": "google", "envVar": "GOOGLE_ACCESS_TOKEN" }
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
If credential exists: binds it. Else: imports from `process.env[envVar]` as api_key (gateway must have that env set).
|
|
156
|
+
|
|
157
|
+
### identity_unset_binding
|
|
158
|
+
|
|
159
|
+
| Param | Type | Required | Description |
|
|
160
|
+
| ---------- | ------ | -------- | --------------------------------------- |
|
|
161
|
+
| `provider` | string | Yes | Provider name to unbind (e.g. `google`) |
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{ "provider": "google" }
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### identity_approve_tool
|
|
168
|
+
|
|
169
|
+
| Param | Type | Required | Description |
|
|
170
|
+
| ------------- | ------ | -------- | --------------------------------------------------------------------------- |
|
|
171
|
+
| `approval_id` | string | Yes | ID from the approval prompt (e.g. after blocking a high-risk exec/write) |
|
|
172
|
+
|
|
173
|
+
Optional tool (not given to agent by default). For human approval, use `/identity approve <id>` or reply "approve" in chat. The agent must NOT call this tool to self-approve. The approval prompt includes the LLM risk reason when available.
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{ "approval_id": "abc123" }
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### identity_risk_check
|
|
180
|
+
|
|
181
|
+
Evaluates risk of a command or tool call before execution. **Call when:** "这个命令安全吗", "is rm -rf dangerous", "check if this is risky", "帮我评估这个命令有没有风险"
|
|
182
|
+
|
|
183
|
+
| Param | Type | Required | Description |
|
|
184
|
+
| ---------- | -------- | -------- | --------------------------------------------------------------------------- |
|
|
185
|
+
| `command` | string | No* | Shell command to evaluate (treated as exec). Use for quick diagnosis. |
|
|
186
|
+
| `toolName` | string | No* | Tool name (e.g. write, apply_patch). Use with params. |
|
|
187
|
+
| `params` | object | No | Tool params. For exec: `{command}`. For write: `{path, content}`. |
|
|
188
|
+
|
|
189
|
+
*Provide either `command` or `toolName`. Returns `risk`, `reason`, `source` (rules or llm). Uses LLM when `authz.enableLlmRiskCheck` is true and rules return medium.
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{ "command": "rm -rf /" }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{ "toolName": "write", "params": { "path": "/etc/hosts", "content": "..." } }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### identity_list_risk_patterns
|
|
200
|
+
|
|
201
|
+
Returns built-in dangerous command patterns and sensitive paths. No params. Use to query what triggers high-risk approval.
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Workflow: Adding a Credential
|
|
208
|
+
|
|
209
|
+
1. **Check login**: `identity_whoami` (brief) or `identity_status` (full). If not logged in, use `identity_login` first (user opens auth URL).
|
|
210
|
+
2. **Add credential**: `identity_fetch` with `provider`. For OAuth2-user, tell user to open `authUrl`; success message sent when done.
|
|
211
|
+
3. **Bind for tools** (optional): `identity_set_binding` so the credential is injected as an env var when tools run.
|
|
212
|
+
|
|
213
|
+
## Workflow: Checking Risk Before Running
|
|
214
|
+
|
|
215
|
+
1. **Diagnose**: `identity_risk_check` with `command` or `toolName`+`params`. Returns risk level and reason.
|
|
216
|
+
2. **List patterns**: `identity_list_risk_patterns` to see what triggers high-risk approval.
|
|
217
|
+
|
|
218
|
+
## Configuration
|
|
219
|
+
|
|
220
|
+
Plugin config lives under `plugins.entries.agent-identity.config`:
|
|
221
|
+
|
|
222
|
+
- `identity`: Identity API (endpoint, credentials, workloadPoolName, workloadName, roleTrn). When `roleTrn` is set (AssumeRole), workload name is omitted; backend uses roleName. When workload not found (404), plugin auto-creates via CreateWorkloadIdentity then retries.
|
|
223
|
+
- `userpool`: OIDC (discoveryUrl, clientId, callbackUrl, or userPoolName+clientName)
|
|
224
|
+
- `authz`: Optional AuthZ (enable, namespaceName, lowRiskBypass, requireRiskApproval, enableLlmRiskCheck, llmRiskCheck). When `enableLlmRiskCheck` is true, rules returning "medium" are re-evaluated via LLM; the risk reason is shown in approval prompts and block messages.
|
|
225
|
+
|
|
226
|
+
## Notes
|
|
227
|
+
|
|
228
|
+
- Requires the agent-identity plugin to be enabled.
|
|
229
|
+
- `/identity` and tools require session context (channel + sender); use from an active chat.
|
|
230
|
+
- `identity_risk_check` and `identity_list_risk_patterns` do not require login.
|