@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.
Files changed (125) hide show
  1. package/README-cn.md +223 -0
  2. package/README.md +223 -0
  3. package/dist/index.d.ts +14 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +306 -0
  6. package/dist/src/actions/identity-actions.d.ts +142 -0
  7. package/dist/src/actions/identity-actions.d.ts.map +1 -0
  8. package/dist/src/actions/identity-actions.js +429 -0
  9. package/dist/src/commands/identity-commands.d.ts +33 -0
  10. package/dist/src/commands/identity-commands.d.ts.map +1 -0
  11. package/dist/src/commands/identity-commands.js +572 -0
  12. package/dist/src/hooks/after-tool-call.d.ts +22 -0
  13. package/dist/src/hooks/after-tool-call.d.ts.map +1 -0
  14. package/dist/src/hooks/after-tool-call.js +35 -0
  15. package/dist/src/hooks/before-agent-start.d.ts +30 -0
  16. package/dist/src/hooks/before-agent-start.d.ts.map +1 -0
  17. package/dist/src/hooks/before-agent-start.js +93 -0
  18. package/dist/src/hooks/before-tool-call.d.ts +38 -0
  19. package/dist/src/hooks/before-tool-call.d.ts.map +1 -0
  20. package/dist/src/hooks/before-tool-call.js +138 -0
  21. package/dist/src/risk/classify-risk.d.ts +24 -0
  22. package/dist/src/risk/classify-risk.d.ts.map +1 -0
  23. package/dist/src/risk/classify-risk.js +61 -0
  24. package/dist/src/risk/diagnose-risk.d.ts +21 -0
  25. package/dist/src/risk/diagnose-risk.d.ts.map +1 -0
  26. package/dist/src/risk/diagnose-risk.js +37 -0
  27. package/dist/src/risk/llm-risk-check.d.ts +27 -0
  28. package/dist/src/risk/llm-risk-check.d.ts.map +1 -0
  29. package/dist/src/risk/llm-risk-check.js +274 -0
  30. package/dist/src/risk/low-risk-tools.d.ts +5 -0
  31. package/dist/src/risk/low-risk-tools.d.ts.map +1 -0
  32. package/dist/src/risk/low-risk-tools.js +29 -0
  33. package/dist/src/routes/oidc-login.d.ts +51 -0
  34. package/dist/src/routes/oidc-login.d.ts.map +1 -0
  35. package/dist/src/routes/oidc-login.js +153 -0
  36. package/dist/src/services/identity-client.d.ts +366 -0
  37. package/dist/src/services/identity-client.d.ts.map +1 -0
  38. package/dist/src/services/identity-client.js +578 -0
  39. package/dist/src/services/identity-credentials.d.ts +28 -0
  40. package/dist/src/services/identity-credentials.d.ts.map +1 -0
  41. package/dist/src/services/identity-credentials.js +170 -0
  42. package/dist/src/services/identity-service.d.ts +33 -0
  43. package/dist/src/services/identity-service.d.ts.map +1 -0
  44. package/dist/src/services/identity-service.js +53 -0
  45. package/dist/src/services/oidc-client.d.ts +57 -0
  46. package/dist/src/services/oidc-client.d.ts.map +1 -0
  47. package/dist/src/services/oidc-client.js +127 -0
  48. package/dist/src/services/send-notification-feishu.d.ts +27 -0
  49. package/dist/src/services/send-notification-feishu.d.ts.map +1 -0
  50. package/dist/src/services/send-notification-feishu.js +148 -0
  51. package/dist/src/services/session-refresh.d.ts +16 -0
  52. package/dist/src/services/session-refresh.d.ts.map +1 -0
  53. package/dist/src/services/session-refresh.js +38 -0
  54. package/dist/src/store/credential-env-bindings.d.ts +16 -0
  55. package/dist/src/store/credential-env-bindings.d.ts.map +1 -0
  56. package/dist/src/store/credential-env-bindings.js +61 -0
  57. package/dist/src/store/credential-store.d.ts +31 -0
  58. package/dist/src/store/credential-store.d.ts.map +1 -0
  59. package/dist/src/store/credential-store.js +57 -0
  60. package/dist/src/store/oidc-state-store.d.ts +15 -0
  61. package/dist/src/store/oidc-state-store.d.ts.map +1 -0
  62. package/dist/src/store/oidc-state-store.js +32 -0
  63. package/dist/src/store/session-store.d.ts +21 -0
  64. package/dist/src/store/session-store.d.ts.map +1 -0
  65. package/dist/src/store/session-store.js +69 -0
  66. package/dist/src/store/tip-store.d.ts +21 -0
  67. package/dist/src/store/tip-store.d.ts.map +1 -0
  68. package/dist/src/store/tip-store.js +60 -0
  69. package/dist/src/store/tool-approval-store.d.ts +44 -0
  70. package/dist/src/store/tool-approval-store.d.ts.map +1 -0
  71. package/dist/src/store/tool-approval-store.js +147 -0
  72. package/dist/src/tools/identity-approve-tool.d.ts +24 -0
  73. package/dist/src/tools/identity-approve-tool.d.ts.map +1 -0
  74. package/dist/src/tools/identity-approve-tool.js +36 -0
  75. package/dist/src/tools/identity-config.d.ts +13 -0
  76. package/dist/src/tools/identity-config.d.ts.map +1 -0
  77. package/dist/src/tools/identity-config.js +18 -0
  78. package/dist/src/tools/identity-fetch.d.ts +21 -0
  79. package/dist/src/tools/identity-fetch.d.ts.map +1 -0
  80. package/dist/src/tools/identity-fetch.js +63 -0
  81. package/dist/src/tools/identity-list-credentials.d.ts +15 -0
  82. package/dist/src/tools/identity-list-credentials.d.ts.map +1 -0
  83. package/dist/src/tools/identity-list-credentials.js +30 -0
  84. package/dist/src/tools/identity-list-risk-patterns.d.ts +13 -0
  85. package/dist/src/tools/identity-list-risk-patterns.d.ts.map +1 -0
  86. package/dist/src/tools/identity-list-risk-patterns.js +23 -0
  87. package/dist/src/tools/identity-list-tips.d.ts +13 -0
  88. package/dist/src/tools/identity-list-tips.d.ts.map +1 -0
  89. package/dist/src/tools/identity-list-tips.js +21 -0
  90. package/dist/src/tools/identity-login.d.ts +14 -0
  91. package/dist/src/tools/identity-login.d.ts.map +1 -0
  92. package/dist/src/tools/identity-login.js +40 -0
  93. package/dist/src/tools/identity-logout.d.ts +13 -0
  94. package/dist/src/tools/identity-logout.d.ts.map +1 -0
  95. package/dist/src/tools/identity-logout.js +24 -0
  96. package/dist/src/tools/identity-risk-check.d.ts +29 -0
  97. package/dist/src/tools/identity-risk-check.d.ts.map +1 -0
  98. package/dist/src/tools/identity-risk-check.js +54 -0
  99. package/dist/src/tools/identity-set-binding.d.ts +16 -0
  100. package/dist/src/tools/identity-set-binding.d.ts.map +1 -0
  101. package/dist/src/tools/identity-set-binding.js +31 -0
  102. package/dist/src/tools/identity-status.d.ts +13 -0
  103. package/dist/src/tools/identity-status.d.ts.map +1 -0
  104. package/dist/src/tools/identity-status.js +41 -0
  105. package/dist/src/tools/identity-unset-binding.d.ts +15 -0
  106. package/dist/src/tools/identity-unset-binding.d.ts.map +1 -0
  107. package/dist/src/tools/identity-unset-binding.js +25 -0
  108. package/dist/src/tools/identity-whoami.d.ts +13 -0
  109. package/dist/src/tools/identity-whoami.d.ts.map +1 -0
  110. package/dist/src/tools/identity-whoami.js +38 -0
  111. package/dist/src/types.d.ts +93 -0
  112. package/dist/src/types.d.ts.map +1 -0
  113. package/dist/src/types.js +5 -0
  114. package/dist/src/utils/approval-channel.d.ts +11 -0
  115. package/dist/src/utils/approval-channel.d.ts.map +1 -0
  116. package/dist/src/utils/approval-channel.js +13 -0
  117. package/dist/src/utils/auth.d.ts +24 -0
  118. package/dist/src/utils/auth.d.ts.map +1 -0
  119. package/dist/src/utils/auth.js +44 -0
  120. package/dist/src/utils/derive-session-key.d.ts +78 -0
  121. package/dist/src/utils/derive-session-key.d.ts.map +1 -0
  122. package/dist/src/utils/derive-session-key.js +198 -0
  123. package/openclaw.plugin.json +162 -0
  124. package/package.json +33 -0
  125. package/skills/SKILL.md +230 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * identity_approve_tool: approve a high-risk tool call by approval_id.
3
+ * Used for webchat/TUI flow when user approves via UI then agent retries.
4
+ */
5
+ import type { PluginToolContext } from "../types.js";
6
+ export type IdentityApproveToolDeps = {
7
+ approvalTtlMs: number;
8
+ logger?: {
9
+ debug?: (msg: string) => void;
10
+ warn?: (msg: string) => void;
11
+ };
12
+ };
13
+ export declare function createIdentityApproveTool(deps: IdentityApproveToolDeps): (ctx: PluginToolContext) => {
14
+ name: string;
15
+ label: string;
16
+ description: string;
17
+ parameters: import("@sinclair/typebox").TObject<{
18
+ approval_id: import("@sinclair/typebox").TString;
19
+ }>;
20
+ execute: (_toolCallId: string, params: {
21
+ approval_id?: string;
22
+ }) => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
23
+ };
24
+ //# sourceMappingURL=identity-approve-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-approve-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-approve-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKrD,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;CAC1E,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,IAC7D,KAAK,iBAAiB;;;;;;;2BAOC,MAAM,UAAU;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;EAwBxE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * identity_approve_tool: approve a high-risk tool call by approval_id.
3
+ * Used for webchat/TUI flow when user approves via UI then agent retries.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { jsonResult } from "openclaw/plugin-sdk";
7
+ import * as toolApprovalStore from "../store/tool-approval-store.js";
8
+ export function createIdentityApproveTool(deps) {
9
+ return (ctx) => ({
10
+ name: "identity_approve_tool",
11
+ label: "Approve Tool Call",
12
+ description: "Approve a pending high-risk tool call by its approval ID. Must run from same session.",
13
+ parameters: Type.Object({
14
+ approval_id: Type.String({ description: "Approval ID from the pending tool message" }),
15
+ }),
16
+ execute: async (_toolCallId, params) => {
17
+ const approvalId = (params?.approval_id ?? "").trim();
18
+ if (!approvalId) {
19
+ return jsonResult({
20
+ ok: false,
21
+ error: "approval_id is required",
22
+ });
23
+ }
24
+ const ok = toolApprovalStore.approve(approvalId, deps.approvalTtlMs, ctx.sessionKey);
25
+ if (ok) {
26
+ deps.logger?.debug?.(`agent-identity: approved tool call ${approvalId}`);
27
+ return jsonResult({ ok: true, message: "Tool call approved" });
28
+ }
29
+ deps.logger?.warn?.(`agent-identity: approve failed for ${approvalId} (expired or not found)`);
30
+ return jsonResult({
31
+ ok: false,
32
+ error: "Approval not found or expired. Request a new tool execution.",
33
+ });
34
+ },
35
+ });
36
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * identity_config: show identity plugin configuration (redacted).
3
+ */
4
+ import type { PluginToolContext } from "../types.js";
5
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
6
+ export declare function createIdentityConfigTool(deps: IdentityActionsDeps): (_ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{}>;
11
+ execute: () => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
12
+ };
13
+ //# sourceMappingURL=identity-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-config.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,mBAAmB,IACxD,MAAM,iBAAiB;;;;;;EAUhC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * identity_config: show identity plugin configuration (redacted).
3
+ */
4
+ import { Type } from "@sinclair/typebox";
5
+ import { jsonResult } from "openclaw/plugin-sdk";
6
+ import { runConfig } from "../actions/identity-actions.js";
7
+ export function createIdentityConfigTool(deps) {
8
+ return (_ctx) => ({
9
+ name: "identity_config",
10
+ label: "Identity Config",
11
+ description: "Show identity plugin configuration (secrets redacted).",
12
+ parameters: Type.Object({}),
13
+ execute: async () => {
14
+ const result = await runConfig(deps);
15
+ return jsonResult(result);
16
+ },
17
+ });
18
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * identity_fetch: add credential for a provider (OAuth2 or API key).
3
+ * For OAuth2 user flow, returns auth URL; polling runs in background.
4
+ * When returnValue is true and fetch succeeds, returns the credential value for same-turn automation.
5
+ */
6
+ import type { PluginToolContext } from "../types.js";
7
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
8
+ export declare function createIdentityFetchTool(deps: IdentityActionsDeps): (ctx: PluginToolContext) => {
9
+ name: string;
10
+ label: string;
11
+ description: string;
12
+ parameters: import("@sinclair/typebox").TObject<{
13
+ provider: import("@sinclair/typebox").TString;
14
+ flow: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<"oauth2-user" | "oauth2-m2m" | "apikey">>;
15
+ redirectUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
16
+ scopes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
17
+ returnValue: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
18
+ }>;
19
+ execute: (_toolCallId: any, params: any) => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
20
+ };
21
+ //# sourceMappingURL=identity-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-fetch.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAM1E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,IACvD,KAAK,iBAAiB;;;;;;;;;;;;EA6D/B"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * identity_fetch: add credential for a provider (OAuth2 or API key).
3
+ * For OAuth2 user flow, returns auth URL; polling runs in background.
4
+ * When returnValue is true and fetch succeeds, returns the credential value for same-turn automation.
5
+ */
6
+ import { Type } from "@sinclair/typebox";
7
+ import { optionalStringEnum } from "openclaw/plugin-sdk";
8
+ import { jsonResult } from "openclaw/plugin-sdk";
9
+ import { runFetch } from "../actions/identity-actions.js";
10
+ import { getCredential, resolveCredentialValue } from "../store/credential-store.js";
11
+ const FETCH_FLOWS = ["oauth2-user", "oauth2-m2m", "apikey"];
12
+ export function createIdentityFetchTool(deps) {
13
+ return (ctx) => ({
14
+ name: "identity_fetch",
15
+ label: "Identity Fetch Credential",
16
+ description: "Add credential for a provider. OAuth2-user returns auth URL to open; apikey/oauth2-m2m complete immediately. Set returnValue=true to receive the credential value for same-turn automation (use with care: value may appear in logs).",
17
+ parameters: Type.Object({
18
+ provider: Type.String({ description: "Provider name (e.g. google, openai)" }),
19
+ flow: Type.Optional(optionalStringEnum(FETCH_FLOWS, {
20
+ description: "oauth2-user (default for 3LO), oauth2-m2m, apikey",
21
+ })),
22
+ redirectUrl: Type.Optional(Type.String()),
23
+ scopes: Type.Optional(Type.Array(Type.String())),
24
+ returnValue: Type.Optional(Type.Boolean({
25
+ description: "When true and fetch succeeds, include credential value in result for same-turn use. Default false.",
26
+ })),
27
+ }),
28
+ execute: async (_toolCallId, params) => {
29
+ const sessionKey = ctx.sessionKey;
30
+ if (!sessionKey) {
31
+ return jsonResult({ error: "No session context", success: false });
32
+ }
33
+ const p = params;
34
+ const result = await runFetch(deps, sessionKey, {
35
+ provider: p.provider,
36
+ flow: p.flow ?? "oauth2-user",
37
+ flowExplicit: p.flow != null,
38
+ redirectUrl: p.redirectUrl,
39
+ scopes: p.scopes,
40
+ deliveryTarget: null,
41
+ config: ctx.config,
42
+ });
43
+ if (result.kind === "success") {
44
+ const out = { success: true, message: result.message };
45
+ if (p.returnValue === true) {
46
+ const cred = await getCredential(deps.storeDir, sessionKey, p.provider);
47
+ const value = cred ? resolveCredentialValue(cred) : undefined;
48
+ if (value)
49
+ out.value = value;
50
+ }
51
+ return jsonResult(out);
52
+ }
53
+ if (result.kind === "auth_url") {
54
+ return jsonResult({
55
+ success: false,
56
+ authUrl: result.authUrl,
57
+ message: result.message,
58
+ });
59
+ }
60
+ return jsonResult({ success: false, error: result.message });
61
+ },
62
+ });
63
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * identity_list_credentials: list credential providers and stored credentials (paginated).
3
+ */
4
+ import type { PluginToolContext } from "../types.js";
5
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
6
+ export declare function createIdentityListCredentialsTool(deps: IdentityActionsDeps): (ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{
11
+ page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
12
+ }>;
13
+ execute: (_toolCallId: any, params: any) => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
14
+ };
15
+ //# sourceMappingURL=identity-list-credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-list-credentials.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-list-credentials.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,mBAAmB,IACjE,KAAK,iBAAiB;;;;;;;;EAsB/B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * identity_list_credentials: list credential providers and stored credentials (paginated).
3
+ */
4
+ import { Type } from "@sinclair/typebox";
5
+ import { jsonResult } from "openclaw/plugin-sdk";
6
+ import { runListCredentials } from "../actions/identity-actions.js";
7
+ export function createIdentityListCredentialsTool(deps) {
8
+ return (ctx) => ({
9
+ name: "identity_list_credentials",
10
+ label: "Identity List Credentials",
11
+ description: "List credential providers and stored credentials (paginated).",
12
+ parameters: Type.Object({
13
+ page: Type.Optional(Type.Number({ minimum: 1, default: 1 })),
14
+ }),
15
+ execute: async (_toolCallId, params) => {
16
+ const sessionKey = ctx.sessionKey;
17
+ if (!sessionKey) {
18
+ return jsonResult({ error: "No session context", providers: [], storedOnly: [] });
19
+ }
20
+ const page = params.page ?? 1;
21
+ const result = await runListCredentials(deps, sessionKey, page);
22
+ return jsonResult({
23
+ providers: result.providers,
24
+ storedOnly: result.storedOnly,
25
+ page: result.page,
26
+ hasMore: result.hasMore,
27
+ });
28
+ },
29
+ });
30
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * identity_list_risk_patterns: list built-in dangerous command patterns and sensitive paths.
3
+ * Use to understand what the plugin considers high-risk before running commands.
4
+ */
5
+ import type { PluginToolContext } from "../types.js";
6
+ export declare function createIdentityListRiskPatternsTool(): (_ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{}>;
11
+ execute: () => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
12
+ };
13
+ //# sourceMappingURL=identity-list-risk-patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-list-risk-patterns.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-list-risk-patterns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKrD,wBAAgB,kCAAkC,KACxC,MAAM,iBAAiB;;;;;;EAehC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * identity_list_risk_patterns: list built-in dangerous command patterns and sensitive paths.
3
+ * Use to understand what the plugin considers high-risk before running commands.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { jsonResult } from "openclaw/plugin-sdk";
7
+ import { getRiskPatterns } from "../risk/classify-risk.js";
8
+ export function createIdentityListRiskPatternsTool() {
9
+ return (_ctx) => ({
10
+ name: "identity_list_risk_patterns",
11
+ label: "List Risk Patterns",
12
+ description: "List built-in dangerous command patterns and sensitive paths. Shows what would trigger high-risk approval.",
13
+ parameters: Type.Object({}),
14
+ execute: async () => {
15
+ const { commandPatterns, sensitivePaths } = getRiskPatterns();
16
+ return jsonResult({
17
+ commandPatterns,
18
+ sensitivePaths,
19
+ note: "Commands matching these patterns (exec/process) or paths (write/edit/apply_patch) require approval when authz is enabled.",
20
+ });
21
+ },
22
+ });
23
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * identity_list_tips: list valid TIP tokens and env bindings.
3
+ */
4
+ import type { PluginToolContext } from "../types.js";
5
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
6
+ export declare function createIdentityListTipsTool(deps: IdentityActionsDeps): (_ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{}>;
11
+ execute: () => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
12
+ };
13
+ //# sourceMappingURL=identity-list-tips.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-list-tips.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-list-tips.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,mBAAmB,IAC1D,MAAM,iBAAiB;;;;;;EAahC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * identity_list_tips: list valid TIP tokens and env bindings.
3
+ */
4
+ import { Type } from "@sinclair/typebox";
5
+ import { jsonResult } from "openclaw/plugin-sdk";
6
+ import { runListTips } from "../actions/identity-actions.js";
7
+ export function createIdentityListTipsTool(deps) {
8
+ return (_ctx) => ({
9
+ name: "identity_list_tips",
10
+ label: "Identity List Tips",
11
+ description: "List valid TIP tokens and credential env bindings.",
12
+ parameters: Type.Object({}),
13
+ execute: async () => {
14
+ const result = await runListTips(deps);
15
+ return jsonResult({
16
+ tips: result.tips,
17
+ bindingsBySession: result.bindingsBySession,
18
+ });
19
+ },
20
+ });
21
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * identity_login: initiate OIDC login or refresh TIP when already logged in.
3
+ * Returns auth URL when login needed; tools don't have deliveryTarget so callback falls back to sessionKey.
4
+ */
5
+ import type { PluginToolContext } from "../types.js";
6
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
7
+ export declare function createIdentityLoginTool(deps: IdentityActionsDeps): (ctx: PluginToolContext) => {
8
+ name: string;
9
+ label: string;
10
+ description: string;
11
+ parameters: import("@sinclair/typebox").TObject<{}>;
12
+ execute: () => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
13
+ };
14
+ //# sourceMappingURL=identity-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-login.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-login.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,IACvD,KAAK,iBAAiB;;;;;;EAiC/B"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * identity_login: initiate OIDC login or refresh TIP when already logged in.
3
+ * Returns auth URL when login needed; tools don't have deliveryTarget so callback falls back to sessionKey.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { jsonResult } from "openclaw/plugin-sdk";
7
+ import { runLogin } from "../actions/identity-actions.js";
8
+ export function createIdentityLoginTool(deps) {
9
+ return (ctx) => ({
10
+ name: "identity_login",
11
+ label: "Identity Login",
12
+ description: "Start OIDC login (returns auth URL to open) or refresh TIP when already logged in. User must open the URL in a browser.",
13
+ parameters: Type.Object({}),
14
+ execute: async () => {
15
+ const sessionKey = ctx.sessionKey;
16
+ if (!sessionKey) {
17
+ return jsonResult({ error: "No session context", authUrl: null });
18
+ }
19
+ const result = await runLogin(deps, sessionKey, {
20
+ config: ctx.config,
21
+ deliveryTarget: null,
22
+ });
23
+ if (result.kind === "already_logged_in") {
24
+ return jsonResult({
25
+ ok: true,
26
+ sub: result.sub,
27
+ message: "Already logged in. TIP refreshed.",
28
+ });
29
+ }
30
+ if (result.kind === "auth_url") {
31
+ return jsonResult({
32
+ ok: false,
33
+ authUrl: result.authUrl,
34
+ message: "Open this URL in a browser to log in. After authorization, a success message will be sent.",
35
+ });
36
+ }
37
+ return jsonResult({ error: result.message, authUrl: null });
38
+ },
39
+ });
40
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * identity_logout: clear session and TIP for the caller's session.
3
+ */
4
+ import type { PluginToolContext } from "../types.js";
5
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
6
+ export declare function createIdentityLogoutTool(deps: IdentityActionsDeps): (ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{}>;
11
+ execute: () => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
12
+ };
13
+ //# sourceMappingURL=identity-logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-logout.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-logout.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,mBAAmB,IACxD,KAAK,iBAAiB;;;;;;EAgB/B"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * identity_logout: clear session and TIP for the caller's session.
3
+ */
4
+ import { Type } from "@sinclair/typebox";
5
+ import { jsonResult } from "openclaw/plugin-sdk";
6
+ import { runLogout } from "../actions/identity-actions.js";
7
+ export function createIdentityLogoutTool(deps) {
8
+ return (ctx) => {
9
+ const sessionKey = ctx.sessionKey;
10
+ return {
11
+ name: "identity_logout",
12
+ label: "Identity Logout",
13
+ description: "Log out the current session and clear TIP cache.",
14
+ parameters: Type.Object({}),
15
+ execute: async () => {
16
+ if (!sessionKey) {
17
+ return jsonResult({ ok: false, error: "No session context" });
18
+ }
19
+ await runLogout(deps, sessionKey);
20
+ return jsonResult({ ok: true });
21
+ },
22
+ };
23
+ };
24
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * identity_risk_check: diagnose risk for a command or tool call without executing.
3
+ * Use before running exec/write to see if it would require approval.
4
+ */
5
+ import type { PluginToolContext } from "../types.js";
6
+ import type { PluginConfig } from "../types.js";
7
+ export type IdentityRiskCheckDeps = {
8
+ pluginConfig: PluginConfig;
9
+ logger?: {
10
+ debug?: (msg: string) => void;
11
+ warn?: (msg: string) => void;
12
+ };
13
+ };
14
+ export declare function createIdentityRiskCheckTool(deps: IdentityRiskCheckDeps): (_ctx: PluginToolContext) => {
15
+ name: string;
16
+ label: string;
17
+ description: string;
18
+ parameters: import("@sinclair/typebox").TObject<{
19
+ command: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
+ toolName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
21
+ params: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
22
+ }>;
23
+ execute: (_toolCallId: string, params: {
24
+ command?: string;
25
+ toolName?: string;
26
+ params?: Record<string, unknown>;
27
+ }) => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
28
+ };
29
+ //# sourceMappingURL=identity-risk-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-risk-check.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-risk-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;CAC1E,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,qBAAqB,IAC7D,MAAM,iBAAiB;;;;;;;;;2BAuBd,MAAM,UACX;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;EAuCtF"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * identity_risk_check: diagnose risk for a command or tool call without executing.
3
+ * Use before running exec/write to see if it would require approval.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { jsonResult } from "openclaw/plugin-sdk";
7
+ import { diagnoseRisk } from "../risk/diagnose-risk.js";
8
+ export function createIdentityRiskCheckTool(deps) {
9
+ return (_ctx) => ({
10
+ name: "identity_risk_check",
11
+ label: "Risk Check",
12
+ description: "Diagnose risk for a shell command or tool call. Pass 'command' for exec, or 'toolName' and 'params' for other tools. Returns risk level and reason.",
13
+ parameters: Type.Object({
14
+ command: Type.Optional(Type.String({
15
+ description: "Shell command to evaluate (treated as exec tool)",
16
+ })),
17
+ toolName: Type.Optional(Type.String({
18
+ description: "Tool name to evaluate (e.g. write, apply_patch). Use with params.",
19
+ })),
20
+ params: Type.Optional(Type.Record(Type.String(), Type.Unknown(), {
21
+ description: "Tool params as object. For exec: {command}. For write: {path, content}.",
22
+ })),
23
+ }),
24
+ execute: async (_toolCallId, params) => {
25
+ const { command, toolName, params: p } = params ?? {};
26
+ let effectiveToolName;
27
+ let effectiveParams;
28
+ if (command != null && command !== "") {
29
+ effectiveToolName = "exec";
30
+ effectiveParams = { command: String(command) };
31
+ }
32
+ else if (toolName != null && toolName.trim() !== "") {
33
+ effectiveToolName = toolName.trim();
34
+ effectiveParams = (p && typeof p === "object" ? p : {});
35
+ }
36
+ else {
37
+ return jsonResult({
38
+ error: "Provide either 'command' (for exec) or 'toolName' (with optional params)",
39
+ });
40
+ }
41
+ const llmConfig = deps.pluginConfig?.authz?.enableLlmRiskCheck && deps.pluginConfig?.authz?.llmRiskCheck
42
+ ? deps.pluginConfig.authz.llmRiskCheck
43
+ : undefined;
44
+ const result = await diagnoseRisk(effectiveToolName, effectiveParams, llmConfig, deps.logger);
45
+ return jsonResult({
46
+ toolName: effectiveToolName,
47
+ params: effectiveParams,
48
+ risk: result.risk,
49
+ reason: result.reason ?? undefined,
50
+ source: result.source,
51
+ });
52
+ },
53
+ });
54
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * identity_set_binding: bind a credential provider to an env var for tool injection.
3
+ */
4
+ import type { PluginToolContext } from "../types.js";
5
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
6
+ export declare function createIdentitySetBindingTool(deps: IdentityActionsDeps): (ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{
11
+ provider: import("@sinclair/typebox").TString;
12
+ envVar: import("@sinclair/typebox").TString;
13
+ }>;
14
+ execute: (_toolCallId: any, params: any) => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
15
+ };
16
+ //# sourceMappingURL=identity-set-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-set-binding.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-set-binding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,mBAAmB,IAC5D,KAAK,iBAAiB;;;;;;;;;EAwB/B"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * identity_set_binding: bind a credential provider to an env var for tool injection.
3
+ */
4
+ import { Type } from "@sinclair/typebox";
5
+ import { jsonResult } from "openclaw/plugin-sdk";
6
+ import { runSetBinding } from "../actions/identity-actions.js";
7
+ export function createIdentitySetBindingTool(deps) {
8
+ return (ctx) => ({
9
+ name: "identity_set_binding",
10
+ label: "Identity Set Binding",
11
+ description: "Bind credential provider to env var. If credential exists, binds it; else imports from process.env[envVar] as api_key.",
12
+ parameters: Type.Object({
13
+ provider: Type.String({ description: "Provider name (e.g. google)" }),
14
+ envVar: Type.String({
15
+ description: "Env var name for injection (e.g. GOOGLE_ACCESS_TOKEN)",
16
+ }),
17
+ }),
18
+ execute: async (_toolCallId, params) => {
19
+ const sessionKey = ctx.sessionKey;
20
+ if (!sessionKey) {
21
+ return jsonResult({ ok: false, error: "No session context" });
22
+ }
23
+ const p = params;
24
+ const result = await runSetBinding(deps, sessionKey, {
25
+ provider: p.provider,
26
+ envVar: p.envVar,
27
+ });
28
+ return jsonResult(result);
29
+ },
30
+ });
31
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * identity_status: return login status, credentials, and env bindings for the caller's session.
3
+ */
4
+ import type { PluginToolContext } from "../types.js";
5
+ import type { IdentityActionsDeps } from "../actions/identity-actions.js";
6
+ export declare function createIdentityStatusTool(deps: IdentityActionsDeps): (ctx: PluginToolContext) => {
7
+ name: string;
8
+ label: string;
9
+ description: string;
10
+ parameters: import("@sinclair/typebox").TObject<{}>;
11
+ execute: () => Promise<import("@mariozechner/pi-agent-core").AgentToolResult<unknown>>;
12
+ };
13
+ //# sourceMappingURL=identity-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-status.d.ts","sourceRoot":"","sources":["../../../src/tools/identity-status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,mBAAmB,IACxD,KAAK,iBAAiB;;;;;;EAiC/B"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * identity_status: return login status, credentials, and env bindings for the caller's session.
3
+ */
4
+ import { Type } from "@sinclair/typebox";
5
+ import { jsonResult } from "openclaw/plugin-sdk";
6
+ import { runStatus } from "../actions/identity-actions.js";
7
+ export function createIdentityStatusTool(deps) {
8
+ return (ctx) => ({
9
+ name: "identity_status",
10
+ label: "Identity Status",
11
+ description: "Show login status, credentials, and env bindings for the current session.",
12
+ parameters: Type.Object({}),
13
+ execute: async () => {
14
+ const sessionKey = ctx.sessionKey;
15
+ if (!sessionKey) {
16
+ return jsonResult({ error: "No session context", loggedIn: false });
17
+ }
18
+ const result = await runStatus(deps, sessionKey, ctx.config);
19
+ return jsonResult({
20
+ loggedIn: result.loggedIn,
21
+ sub: result.sub,
22
+ hasTip: result.hasTip,
23
+ session: result.sessionLoginAt
24
+ ? {
25
+ loginAt: result.sessionLoginAt,
26
+ expiresAt: result.sessionExpiresAt ?? undefined,
27
+ }
28
+ : undefined,
29
+ tip: result.hasTip && result.tipExpiresAt
30
+ ? {
31
+ issuedAt: result.tipIssuedAt,
32
+ expiresAt: result.tipExpiresAt,
33
+ chain: result.tipChain,
34
+ }
35
+ : undefined,
36
+ credentialProviders: Object.keys(result.credentials),
37
+ bindings: result.bindings,
38
+ });
39
+ },
40
+ });
41
+ }