@shieldaai/agent-map 0.0.0-stage → 0.1.0-alpha.3
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/LICENSE +202 -0
- package/README.md +312 -2
- package/dist/assets.d.ts +5 -0
- package/dist/assets.js +43 -0
- package/dist/boundary.d.ts +7 -0
- package/dist/boundary.js +123 -0
- package/dist/cli-entry.d.ts +2 -0
- package/dist/cli-entry.js +18 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +93 -0
- package/dist/http.d.ts +28 -0
- package/dist/http.js +233 -0
- package/dist/identity-cli.d.ts +9 -0
- package/dist/identity-cli.js +103 -0
- package/dist/identity-http.d.ts +44 -0
- package/dist/identity-http.js +394 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.js +31 -0
- package/dist/oidc.d.ts +27 -0
- package/dist/oidc.js +311 -0
- package/dist/policy-reader.d.ts +28 -0
- package/dist/policy-reader.js +394 -0
- package/dist/service.d.ts +28 -0
- package/dist/service.js +683 -0
- package/dist/store.d.ts +24 -0
- package/dist/store.js +466 -0
- package/dist/transport.d.ts +11 -0
- package/dist/transport.js +70 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.js +47 -0
- package/package.json +59 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
2
|
+
readonly [key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
export type JsonObject = {
|
|
5
|
+
readonly [key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
export declare class MapQueryError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
constructor(code: string);
|
|
10
|
+
}
|
|
11
|
+
export interface ReadScope {
|
|
12
|
+
readonly subject: string;
|
|
13
|
+
readonly companyId: string;
|
|
14
|
+
readonly tenantIds: readonly string[];
|
|
15
|
+
readonly teamIds: readonly string[];
|
|
16
|
+
readonly allTeams: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const MAP_LABELS: readonly ['GuardAgent', 'GuardDeployment', 'GuardTask', 'GuardPrincipal', 'GuardGrant', 'GuardTool', 'GuardResource', 'GuardResourceBinding', 'GuardExecutionBinding', 'GuardExternalResource', 'GuardExternalIdentity', 'GuardMcpConnection', 'GuardMcpOperation'];
|
|
19
|
+
export type GuardLabel = typeof MAP_LABELS[number];
|
|
20
|
+
export declare const MAP_RELATIONSHIPS: readonly ['G_INSTANCE_OF', 'G_ASSIGNED_TO', 'G_ACTS_AS', 'G_DELEGATED_FROM', 'G_DERIVED_FROM', 'G_HAS_GRANT', 'G_FOR_TOOL', 'G_TARGETS', 'G_BINDS_SELECTOR', 'G_MAPS_TO', 'G_EXECUTES_FOR', 'G_EXECUTES_TOOL', 'G_USES_IDENTITY', 'G_VIA_CONNECTION', 'G_EXPOSES_OPERATION', 'G_OPERATION_TOOL'];
|
|
21
|
+
export type GuardRelation = typeof MAP_RELATIONSHIPS[number];
|
|
22
|
+
export interface MapNode {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly entityId: string;
|
|
25
|
+
readonly label: GuardLabel;
|
|
26
|
+
readonly sourceId: string;
|
|
27
|
+
readonly projectionId: string;
|
|
28
|
+
readonly properties: JsonObject;
|
|
29
|
+
}
|
|
30
|
+
export interface MapEdge {
|
|
31
|
+
readonly source: string;
|
|
32
|
+
readonly target: string;
|
|
33
|
+
readonly kind: GuardRelation;
|
|
34
|
+
}
|
|
35
|
+
export interface MapCoverage {
|
|
36
|
+
readonly [component: string]: {
|
|
37
|
+
readonly status: string;
|
|
38
|
+
readonly observedAt?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface MapPolicyCandidate {
|
|
42
|
+
readonly relationship: 'CAN_READ' | 'CAN_WRITE' | 'CAN_LIST';
|
|
43
|
+
readonly hasCondition: boolean;
|
|
44
|
+
readonly conditionKeys: readonly string[];
|
|
45
|
+
readonly resourceScope: 'bucket_summary';
|
|
46
|
+
}
|
|
47
|
+
export interface MapPolicyEvidence {
|
|
48
|
+
readonly taskId: string;
|
|
49
|
+
readonly deploymentId: string;
|
|
50
|
+
readonly executionBindingId: string;
|
|
51
|
+
readonly resourceBindingId: string;
|
|
52
|
+
readonly identityId: string | null;
|
|
53
|
+
readonly resourceId: string | null;
|
|
54
|
+
readonly action: string;
|
|
55
|
+
readonly status: 'complete' | 'unavailable' | 'not_collected';
|
|
56
|
+
readonly reason: 'no_candidate' | 'binding_ambiguous' | 'cloud_unresolved' | 'provider_missing' | 'collection_invalid' | 'stale' | 'changed' | 'boundary_unresolved' | 'unsupported_policy' | 'evidence_invalid' | 'unsupported_action' | 'identity_not_static' | 'unsupported_binding' | 'cloud_not_collected' | 'collection_missing' | 'disabled' | null;
|
|
57
|
+
readonly observedAt: string | null;
|
|
58
|
+
readonly assessment: 'unknown';
|
|
59
|
+
readonly candidates: readonly MapPolicyCandidate[];
|
|
60
|
+
}
|
|
61
|
+
export interface MapProjection {
|
|
62
|
+
readonly id: string;
|
|
63
|
+
readonly snapshotId: string;
|
|
64
|
+
readonly generatedAt: string;
|
|
65
|
+
readonly status: 'published';
|
|
66
|
+
readonly nodes: readonly MapNode[];
|
|
67
|
+
readonly edges: readonly MapEdge[];
|
|
68
|
+
readonly coverage: MapCoverage;
|
|
69
|
+
/** Current, independently checked policy evidence; omitted for summaries/history. */
|
|
70
|
+
readonly policyEvidence?: readonly MapPolicyEvidence[];
|
|
71
|
+
}
|
|
72
|
+
export interface MapSource {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly tenantId: string;
|
|
75
|
+
readonly sourceId: string;
|
|
76
|
+
readonly profile: 'core' | 'host' | 'host-mcp';
|
|
77
|
+
readonly current: MapProjection;
|
|
78
|
+
readonly previous: MapProjection | null;
|
|
79
|
+
}
|
|
80
|
+
export interface MapView {
|
|
81
|
+
readonly sources: readonly MapSource[];
|
|
82
|
+
}
|
|
83
|
+
export interface MapReadRequest {
|
|
84
|
+
readonly sourceId?: string;
|
|
85
|
+
readonly agentId?: string;
|
|
86
|
+
readonly history?: boolean;
|
|
87
|
+
/** Agent/deployment index only; avoids loading task neighborhoods before selecting an agent. */
|
|
88
|
+
readonly summary?: boolean;
|
|
89
|
+
}
|
|
90
|
+
export interface MapStore {
|
|
91
|
+
read(scope: ReadScope, request?: MapReadRequest): Promise<MapView>;
|
|
92
|
+
}
|
|
93
|
+
export declare function mapIdentifier(value: unknown, code?: string): string;
|
|
94
|
+
export declare function validateReadScope(value: unknown): ReadScope;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { immutableJson } from '@shieldaai/agent-guard';
|
|
2
|
+
export class MapQueryError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code) {
|
|
5
|
+
super(code);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = 'MapQueryError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const MAP_LABELS = ['GuardAgent', 'GuardDeployment', 'GuardTask', 'GuardPrincipal', 'GuardGrant',
|
|
11
|
+
'GuardTool', 'GuardResource', 'GuardResourceBinding', 'GuardExecutionBinding', 'GuardExternalResource',
|
|
12
|
+
'GuardExternalIdentity', 'GuardMcpConnection', 'GuardMcpOperation'];
|
|
13
|
+
export const MAP_RELATIONSHIPS = ['G_INSTANCE_OF', 'G_ASSIGNED_TO', 'G_ACTS_AS', 'G_DELEGATED_FROM',
|
|
14
|
+
'G_DERIVED_FROM', 'G_HAS_GRANT', 'G_FOR_TOOL', 'G_TARGETS', 'G_BINDS_SELECTOR', 'G_MAPS_TO',
|
|
15
|
+
'G_EXECUTES_FOR', 'G_EXECUTES_TOOL', 'G_USES_IDENTITY', 'G_VIA_CONNECTION', 'G_EXPOSES_OPERATION',
|
|
16
|
+
'G_OPERATION_TOOL'];
|
|
17
|
+
export function mapIdentifier(value, code = 'MAP_REQUEST_INVALID') {
|
|
18
|
+
if (typeof value !== 'string' || !value.trim() || [...value].length > 4096 || value.includes('\0') ||
|
|
19
|
+
/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(value))
|
|
20
|
+
throw new MapQueryError(code);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
export function validateReadScope(value) {
|
|
24
|
+
try {
|
|
25
|
+
const copied = immutableJson(value, 4, 1024, 64 * 1024);
|
|
26
|
+
if (!copied || Array.isArray(copied) || typeof copied !== 'object' ||
|
|
27
|
+
Object.keys(copied).sort().join(',') !== 'allTeams,companyId,subject,teamIds,tenantIds')
|
|
28
|
+
throw new Error();
|
|
29
|
+
mapIdentifier(copied.subject);
|
|
30
|
+
mapIdentifier(copied.companyId);
|
|
31
|
+
if (typeof copied.allTeams !== 'boolean')
|
|
32
|
+
throw new Error();
|
|
33
|
+
for (const key of ['tenantIds', 'teamIds']) {
|
|
34
|
+
const items = copied[key];
|
|
35
|
+
if (!Array.isArray(items) || items.length > 128 || (key === 'tenantIds' && items.length === 0) ||
|
|
36
|
+
new Set(items).size !== items.length)
|
|
37
|
+
throw new Error();
|
|
38
|
+
items.forEach(item => mapIdentifier(item));
|
|
39
|
+
}
|
|
40
|
+
if (!copied.allTeams && copied.teamIds.length === 0)
|
|
41
|
+
throw new Error();
|
|
42
|
+
return copied;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw new MapQueryError('MAP_SCOPE_INVALID');
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shieldaai/agent-map",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
|
+
"description": "Read-only AI agent and MCP inventory queries over HTTP and MCP, with scoped access to Cartography projections.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"agent-guard-map": "./dist/cli.js",
|
|
17
|
+
"agent-guard-map-identity": "./dist/identity-cli.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.13.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
29
|
+
"@shieldaai/agent-guard": "0.1.0-alpha.3",
|
|
30
|
+
"neo4j-driver": "6.3.0",
|
|
31
|
+
"openid-client": "6.8.8"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"tag": "alpha"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/ShieldaAI/agent-guard.git",
|
|
40
|
+
"directory": "packages/agent-map"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"prepack": "node ../../scripts/build.mjs",
|
|
45
|
+
"prepublishOnly": "node ../../scripts/release-check.mjs"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/ShieldaAI/agent-guard/tree/main/packages/agent-map#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/ShieldaAI/agent-guard/issues"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"ai-agents",
|
|
53
|
+
"agent-inventory",
|
|
54
|
+
"mcp",
|
|
55
|
+
"model-context-protocol",
|
|
56
|
+
"cartography",
|
|
57
|
+
"neo4j",
|
|
58
|
+
"typescript",
|
|
59
|
+
"access-explanations"
|
|
60
|
+
]
|
|
61
|
+
}
|