@mandate-os/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.
@@ -0,0 +1,81 @@
1
+ import type { ToolId } from './mandates';
2
+ export declare const mandateOsGenericEvaluateToolName = "mandateos_evaluate_actions";
3
+ export declare const mandateOsGenericEnforcedExecuteToolName = "mandateos_execute_enforced_action";
4
+ export type EnforcementIntegration = 'mcp' | 'openclaw';
5
+ export declare const enforcementRouteDefinitions: readonly [{
6
+ readonly route: "enforced.github.issue.label";
7
+ readonly integration: "mcp";
8
+ readonly recommendedTool: "mandateos_execute_enforced_action";
9
+ readonly kind: "github.issue.label";
10
+ readonly actionTool: "issue.label";
11
+ readonly legacyToolName: "mandateos_execute_github_issue_label";
12
+ readonly executePath: "/api/v1/integrations/github/issue-label/execute";
13
+ }, {
14
+ readonly route: "enforced.github.pull_request.draft";
15
+ readonly integration: "mcp";
16
+ readonly recommendedTool: "mandateos_execute_enforced_action";
17
+ readonly kind: "github.pull_request.draft";
18
+ readonly actionTool: "pr.draft";
19
+ readonly legacyToolName: "mandateos_execute_github_pull_request_draft";
20
+ readonly executePath: "/api/v1/integrations/github/pull-request/draft/execute";
21
+ }, {
22
+ readonly route: "enforced.openclaw.exec";
23
+ readonly integration: "openclaw";
24
+ readonly recommendedTool: "mandateos_openclaw_exec";
25
+ }, {
26
+ readonly route: "enforced.openclaw.browser.mutate";
27
+ readonly integration: "openclaw";
28
+ readonly recommendedTool: "mandateos_openclaw_browser_mutate";
29
+ }, {
30
+ readonly route: "enforced.openclaw.agent.spawn";
31
+ readonly integration: "openclaw";
32
+ readonly recommendedTool: "mandateos_openclaw_spawn_agent";
33
+ }];
34
+ export type EnforcedRouteDefinition = (typeof enforcementRouteDefinitions)[number];
35
+ export type EnforcedRouteId = EnforcedRouteDefinition['route'];
36
+ export type PolicyGatewayRoute = 'generic' | EnforcedRouteId;
37
+ export type EnforcedExecutionCapability = Extract<EnforcedRouteDefinition, {
38
+ kind: string;
39
+ actionTool: ToolId;
40
+ executePath: string;
41
+ }>;
42
+ export type EnforcedExecutionKind = EnforcedExecutionCapability['kind'];
43
+ export declare function isPolicyGatewayRoute(value: string): value is PolicyGatewayRoute;
44
+ export declare function isEnforcedExecutionKind(value: string): value is EnforcedExecutionKind;
45
+ export declare function getEnforcedRouteDefinition(route: EnforcedRouteId): {
46
+ readonly route: "enforced.github.issue.label";
47
+ readonly integration: "mcp";
48
+ readonly recommendedTool: "mandateos_execute_enforced_action";
49
+ readonly kind: "github.issue.label";
50
+ readonly actionTool: "issue.label";
51
+ readonly legacyToolName: "mandateos_execute_github_issue_label";
52
+ readonly executePath: "/api/v1/integrations/github/issue-label/execute";
53
+ } | {
54
+ readonly route: "enforced.github.pull_request.draft";
55
+ readonly integration: "mcp";
56
+ readonly recommendedTool: "mandateos_execute_enforced_action";
57
+ readonly kind: "github.pull_request.draft";
58
+ readonly actionTool: "pr.draft";
59
+ readonly legacyToolName: "mandateos_execute_github_pull_request_draft";
60
+ readonly executePath: "/api/v1/integrations/github/pull-request/draft/execute";
61
+ } | {
62
+ readonly route: "enforced.openclaw.exec";
63
+ readonly integration: "openclaw";
64
+ readonly recommendedTool: "mandateos_openclaw_exec";
65
+ } | {
66
+ readonly route: "enforced.openclaw.browser.mutate";
67
+ readonly integration: "openclaw";
68
+ readonly recommendedTool: "mandateos_openclaw_browser_mutate";
69
+ } | {
70
+ readonly route: "enforced.openclaw.agent.spawn";
71
+ readonly integration: "openclaw";
72
+ readonly recommendedTool: "mandateos_openclaw_spawn_agent";
73
+ };
74
+ export declare function getEnforcedExecutionCapability(kind: EnforcedExecutionKind): EnforcedExecutionCapability;
75
+ export declare function recommendedToolForRoute(route: PolicyGatewayRoute): "mandateos_evaluate_actions" | "mandateos_execute_enforced_action" | "mandateos_openclaw_exec" | "mandateos_openclaw_browser_mutate" | "mandateos_openclaw_spawn_agent";
76
+ export declare function listMandateOsEnforcedToolNames(integration?: EnforcementIntegration, options?: {
77
+ includeLegacyToolNames?: boolean;
78
+ }): string[];
79
+ export declare function getLegacyToolNameForExecutionKind(kind: EnforcedExecutionKind): "mandateos_execute_github_issue_label" | "mandateos_execute_github_pull_request_draft" | undefined;
80
+ export declare function getExpectedActionToolForExecutionKind(kind: EnforcedExecutionKind): "issue.label" | "pr.draft";
81
+ //# sourceMappingURL=enforced-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enforced-capabilities.d.ts","sourceRoot":"","sources":["../../../packages/mandate-os-sdk/src/enforced-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,gCAAgC,+BAA+B,CAAC;AAC7E,eAAO,MAAM,uCAAuC,sCACf,CAAC;AAEtC,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,UAAU,CAAC;AAIxD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/C,MAAM,MAAM,eAAe,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,eAAe,CAAC;AAC7D,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAC/C,uBAAuB,EACvB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CACF,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;AAExE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,kBAAkB,CAK7B;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,qBAAqB,CAIhC;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUhE;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,qBAAqB,GAanD,2BAA2B,CACjD;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,2KAMhE;AAED,wBAAgB,8BAA8B,CAC5C,WAAW,CAAC,EAAE,sBAAsB,EACpC,OAAO,GAAE;IACP,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC7B,YAiBP;AAED,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,qBAAqB,sGAI5E;AAED,wBAAgB,qCAAqC,CACnD,IAAI,EAAE,qBAAqB,8BAG5B"}
@@ -0,0 +1,89 @@
1
+ export const mandateOsGenericEvaluateToolName = 'mandateos_evaluate_actions';
2
+ export const mandateOsGenericEnforcedExecuteToolName = 'mandateos_execute_enforced_action';
3
+ // Central registry for enforced capabilities. Add new routes here so policy
4
+ // redirects, generic execute flows, and host tool discovery stay aligned.
5
+ export const enforcementRouteDefinitions = [
6
+ {
7
+ route: 'enforced.github.issue.label',
8
+ integration: 'mcp',
9
+ recommendedTool: mandateOsGenericEnforcedExecuteToolName,
10
+ kind: 'github.issue.label',
11
+ actionTool: 'issue.label',
12
+ legacyToolName: 'mandateos_execute_github_issue_label',
13
+ executePath: '/api/v1/integrations/github/issue-label/execute',
14
+ },
15
+ {
16
+ route: 'enforced.github.pull_request.draft',
17
+ integration: 'mcp',
18
+ recommendedTool: mandateOsGenericEnforcedExecuteToolName,
19
+ kind: 'github.pull_request.draft',
20
+ actionTool: 'pr.draft',
21
+ legacyToolName: 'mandateos_execute_github_pull_request_draft',
22
+ executePath: '/api/v1/integrations/github/pull-request/draft/execute',
23
+ },
24
+ {
25
+ route: 'enforced.openclaw.exec',
26
+ integration: 'openclaw',
27
+ recommendedTool: 'mandateos_openclaw_exec',
28
+ },
29
+ {
30
+ route: 'enforced.openclaw.browser.mutate',
31
+ integration: 'openclaw',
32
+ recommendedTool: 'mandateos_openclaw_browser_mutate',
33
+ },
34
+ {
35
+ route: 'enforced.openclaw.agent.spawn',
36
+ integration: 'openclaw',
37
+ recommendedTool: 'mandateos_openclaw_spawn_agent',
38
+ },
39
+ ];
40
+ export function isPolicyGatewayRoute(value) {
41
+ return (value === 'generic' ||
42
+ enforcementRouteDefinitions.some((definition) => definition.route === value));
43
+ }
44
+ export function isEnforcedExecutionKind(value) {
45
+ return enforcementRouteDefinitions.some((definition) => 'kind' in definition && definition.kind === value);
46
+ }
47
+ export function getEnforcedRouteDefinition(route) {
48
+ const definition = enforcementRouteDefinitions.find((entry) => entry.route === route);
49
+ if (!definition) {
50
+ throw new Error(`Unknown MandateOS enforced route: ${route}`);
51
+ }
52
+ return definition;
53
+ }
54
+ export function getEnforcedExecutionCapability(kind) {
55
+ const definition = enforcementRouteDefinitions.find((entry) => 'kind' in entry && entry.kind === kind);
56
+ if (!definition ||
57
+ !('actionTool' in definition) ||
58
+ !('executePath' in definition)) {
59
+ throw new Error(`Unknown MandateOS enforced execution kind: ${kind}`);
60
+ }
61
+ return definition;
62
+ }
63
+ export function recommendedToolForRoute(route) {
64
+ if (route === 'generic') {
65
+ return mandateOsGenericEvaluateToolName;
66
+ }
67
+ return getEnforcedRouteDefinition(route).recommendedTool;
68
+ }
69
+ export function listMandateOsEnforcedToolNames(integration, options = {}) {
70
+ const toolNames = new Set();
71
+ for (const definition of enforcementRouteDefinitions) {
72
+ if (integration && definition.integration !== integration) {
73
+ continue;
74
+ }
75
+ toolNames.add(definition.recommendedTool);
76
+ if (options.includeLegacyToolNames && 'legacyToolName' in definition) {
77
+ toolNames.add(definition.legacyToolName);
78
+ }
79
+ }
80
+ return [...toolNames];
81
+ }
82
+ export function getLegacyToolNameForExecutionKind(kind) {
83
+ const definition = getEnforcedExecutionCapability(kind);
84
+ return 'legacyToolName' in definition ? definition.legacyToolName : undefined;
85
+ }
86
+ export function getExpectedActionToolForExecutionKind(kind) {
87
+ return getEnforcedExecutionCapability(kind).actionTool;
88
+ }
89
+ //# sourceMappingURL=enforced-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enforced-capabilities.js","sourceRoot":"","sources":["../../../packages/mandate-os-sdk/src/enforced-capabilities.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gCAAgC,GAAG,4BAA4B,CAAC;AAC7E,MAAM,CAAC,MAAM,uCAAuC,GAClD,mCAAmC,CAAC;AAItC,4EAA4E;AAC5E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC;QACE,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,uCAAuC;QACxD,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE,aAAa;QACzB,cAAc,EAAE,sCAAsC;QACtD,WAAW,EAAE,iDAAiD;KAC/D;IACD;QACE,KAAK,EAAE,oCAAoC;QAC3C,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,uCAAuC;QACxD,IAAI,EAAE,2BAA2B;QACjC,UAAU,EAAE,UAAU;QACtB,cAAc,EAAE,6CAA6C;QAC7D,WAAW,EAAE,wDAAwD;KACtE;IACD;QACE,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EAAE,UAAU;QACvB,eAAe,EAAE,yBAAyB;KAC3C;IACD;QACE,KAAK,EAAE,kCAAkC;QACzC,WAAW,EAAE,UAAU;QACvB,eAAe,EAAE,mCAAmC;KACrD;IACD;QACE,KAAK,EAAE,+BAA+B;QACtC,WAAW,EAAE,UAAU;QACvB,eAAe,EAAE,gCAAgC;KAClD;CACO,CAAC;AAgBX,MAAM,UAAU,oBAAoB,CAClC,KAAa;IAEb,OAAO,CACL,KAAK,KAAK,SAAS;QACnB,2BAA2B,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,KAAK,KAAK,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,K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I,WAAW,IAAI,UAAU,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;YAC1D,SAAS;QACX,CAAC;QAED,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAE1C,IAAI,OAAO,CAAC,sBAAsB,IAAI,gBAAgB,IAAI,UAAU,EAAE,CAAC;YACrE,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,IAA2B;IAC3E,MAAM,UAAU,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAC;IAExD,OAAO,gBAAgB,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,qCAAqC,CACnD,IAA2B;IAE3B,OAAO,8BAA8B,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;AACzD,CAAC"}
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './agent-client';
2
+ export * from './agent-middleware';
3
+ export * from './contracts';
4
+ export * from './enforced-capabilities';
5
+ export * from './mandates';
6
+ export * from './policy-gateway';
7
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/mandate-os-sdk/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from './agent-client';
2
+ export * from './agent-middleware';
3
+ export * from './contracts';
4
+ export * from './enforced-capabilities';
5
+ export * from './mandates';
6
+ export * from './policy-gateway';
7
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/mandate-os-sdk/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
package/mandates.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ export declare const toolIds: readonly ["repo.read", "issue.label", "pr.draft", "docs.publish", "erp.read", "quote.request", "contract.draft", "payment.execute", "deploy.prod", "support.refund", "shell.exec", "browser.read", "browser.mutate", "agent.spawn", "node.command", "session.control"];
2
+ export declare const regionIds: readonly ["eea", "oecd", "global"];
3
+ export declare const decisions: readonly ["allowed", "approval", "blocked"];
4
+ export declare const riskLevels: readonly ["low", "medium", "high"];
5
+ export declare const zones: readonly ["domestic", "eea", "oecd", "restricted"];
6
+ export type ToolId = (typeof toolIds)[number];
7
+ export type RegionId = (typeof regionIds)[number];
8
+ export type Decision = (typeof decisions)[number];
9
+ export type RiskLevel = (typeof riskLevels)[number];
10
+ export type Zone = (typeof zones)[number];
11
+ export declare function isToolId(value: string): value is ToolId;
12
+ export declare function isRiskLevel(value: string): value is RiskLevel;
13
+ export declare function isZone(value: string): value is Zone;
14
+ export type MandateDraft = {
15
+ presetId: string;
16
+ owner: string;
17
+ agentName: string;
18
+ purpose: string;
19
+ monthlyCapNok: number;
20
+ approvalTermMonths: number;
21
+ allowedRegion: RegionId;
22
+ allowedTools: ToolId[];
23
+ };
24
+ export type ActionScenario = {
25
+ id: string;
26
+ title: string;
27
+ description: string;
28
+ tool: ToolId;
29
+ amountNok: number;
30
+ termMonths: number;
31
+ zone: Zone;
32
+ riskLevel: RiskLevel;
33
+ receiptSuffix: string;
34
+ };
35
+ //# sourceMappingURL=mandates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AM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC"}
package/mandates.js ADDED
@@ -0,0 +1,32 @@
1
+ export const toolIds = [
2
+ 'repo.read',
3
+ 'issue.label',
4
+ 'pr.draft',
5
+ 'docs.publish',
6
+ 'erp.read',
7
+ 'quote.request',
8
+ 'contract.draft',
9
+ 'payment.execute',
10
+ 'deploy.prod',
11
+ 'support.refund',
12
+ 'shell.exec',
13
+ 'browser.read',
14
+ 'browser.mutate',
15
+ 'agent.spawn',
16
+ 'node.command',
17
+ 'session.control',
18
+ ];
19
+ export const regionIds = ['eea', 'oecd', 'global'];
20
+ export const decisions = ['allowed', 'approval', 'blocked'];
21
+ export const riskLevels = ['low', 'medium', 'high'];
22
+ export const zones = ['domestic', 'eea', 'oecd', 'restricted'];
23
+ export function isToolId(value) {
24
+ return toolIds.includes(value);
25
+ }
26
+ export function isRiskLevel(value) {
27
+ return riskLevels.includes(value);
28
+ }
29
+ export function isZone(value) {
30
+ return zones.includes(value);
31
+ }
32
+ //# sourceMappingURL=mandates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mandates.js","sourceRoot":"","sources":["../../../packages/mandate-os-sdk/src/mandates.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,WAAW;IACX,aAAa;IACb,UAAU;IACV,cAAc;IACd,UAAU;IACV,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,cAAc;IACd,iBAAiB;CACT,CAAC;AAEX,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAC7D,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAU,CAAC;AAQxE,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAe,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAkB,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAa,CAAC,CAAC;AACvC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@mandate-os/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for MandateOS agent integrations.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "main": "./index.js",
12
+ "module": "./index.js",
13
+ "types": "./index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./index.d.ts",
17
+ "import": "./index.js"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,78 @@
1
+ import type { ReceiptRecord, RuntimeSimulationBatch } from './contracts';
2
+ import type { ActionScenario, RiskLevel, ToolId, Zone } from './mandates';
3
+ import type { MandateOsAgentClient } from './agent-client';
4
+ import { type PolicyGatewayRoute } from './enforced-capabilities';
5
+ export type PolicyGatewayPermission = 'allow' | 'ask' | 'deny';
6
+ export type PolicyGatewayChannel = 'shell' | 'mcp' | 'browser' | 'agent' | 'node' | 'session';
7
+ export type MandateOsPolicyGatewayRule = {
8
+ id: string;
9
+ channel: PolicyGatewayChannel;
10
+ matcher: string | RegExp;
11
+ flags?: string;
12
+ tool: ToolId;
13
+ title: string;
14
+ description: string;
15
+ amountNok?: number;
16
+ termMonths?: number;
17
+ zone: Zone;
18
+ riskLevel: RiskLevel;
19
+ route?: PolicyGatewayRoute;
20
+ };
21
+ export type MandateOsPolicyGatewayOptions = {
22
+ client: Pick<MandateOsAgentClient, 'evaluateActions'>;
23
+ defaultMandateId?: string;
24
+ defaultSource?: string;
25
+ hostName?: string;
26
+ unmatchedPermission?: PolicyGatewayPermission;
27
+ rules: MandateOsPolicyGatewayRule[];
28
+ };
29
+ export type PolicyGatewayDecision = 'local_allow' | 'policy_allowed' | 'policy_approval' | 'policy_blocked' | 'redirect_enforced' | 'unmatched' | 'misconfigured';
30
+ export type PolicyGatewayEvaluationResult = {
31
+ permission: PolicyGatewayPermission;
32
+ decision: PolicyGatewayDecision;
33
+ ruleId?: string;
34
+ route?: PolicyGatewayRoute;
35
+ action?: ActionScenario;
36
+ receipt?: ReceiptRecord;
37
+ evaluation?: RuntimeSimulationBatch;
38
+ userMessage?: string;
39
+ agentMessage?: string;
40
+ recommendedTool?: string;
41
+ };
42
+ export type PolicyGatewayAttempt = {
43
+ channel: PolicyGatewayChannel;
44
+ subject: string;
45
+ mandateId?: string;
46
+ source?: string;
47
+ host?: string;
48
+ details?: Record<string, unknown>;
49
+ context?: Record<string, unknown>;
50
+ };
51
+ export declare const readOnlyShellPatterns: readonly [RegExp, RegExp, RegExp, RegExp];
52
+ export declare const defaultHostGatewayRules: MandateOsPolicyGatewayRule[];
53
+ export declare const openClawPolicyGatewayRules: MandateOsPolicyGatewayRule[];
54
+ export declare class MandateOsPolicyGateway {
55
+ private readonly options;
56
+ private readonly defaultMandateId?;
57
+ private readonly defaultSource?;
58
+ private readonly hostName;
59
+ private readonly unmatchedPermission;
60
+ private readonly rules;
61
+ constructor(options: MandateOsPolicyGatewayOptions);
62
+ evaluateAttempt(input: PolicyGatewayAttempt): Promise<PolicyGatewayEvaluationResult>;
63
+ createUnmatchedResult(channel: PolicyGatewayChannel, agentMessage: string): PolicyGatewayEvaluationResult;
64
+ private findRule;
65
+ private evaluateMatchedAttempt;
66
+ }
67
+ export declare function parsePolicyGatewayRules(input: unknown): MandateOsPolicyGatewayRule[];
68
+ export declare function normalizeMcpToolName(value: string): string;
69
+ export declare function isMandateOsToolName(value: string): boolean;
70
+ export declare function summarizeJson(value: unknown): string;
71
+ export declare function isReadOnlyShellCommand(command: string): boolean;
72
+ export declare function isPolicyGatewayChannel(value: string): value is PolicyGatewayChannel;
73
+ export declare function normalizePermission(value: unknown, fallback: PolicyGatewayPermission): PolicyGatewayPermission;
74
+ export declare function normalizeOptionalText(value: unknown): string;
75
+ export declare function normalizeOptionalNumber(value: unknown): number | undefined;
76
+ export declare function splitCommaSeparatedList(value: string): string[];
77
+ export declare function truncate(value: string, maxLength: number): string;
78
+ //# sourceMappingURL=policy-gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-gateway.d.ts","sourceRoot":"","sources":["../../../packages/mandate-os-sdk/src/policy-gateway.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAC/D,MAAM,MAAM,oBAAoB,GAC5B,OAAO,GACP,KAAK,GACL,SAAS,GACT,OAA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