@shipfox/api-agent-access 20.3.0 → 20.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/core/rate-limiter.js +1 -1
- package/dist/core/rate-limiter.js.map +1 -1
- package/dist/presentation/audit.js +2 -2
- package/dist/presentation/audit.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/core/paged-tools.test.ts +1 -1
- package/src/core/rate-limiter.test.ts +2 -3
- package/src/core/rate-limiter.ts +1 -3
- package/src/core/tools.test.ts +1 -1
- package/src/presentation/audit.test.ts +7 -10
- package/src/presentation/audit.ts +2 -2
- package/src/presentation/mcp-server.test.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-agent-access",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.4.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
35
35
|
"@shipfox/api-agent-access-dto": "20.3.0",
|
|
36
36
|
"@shipfox/annotations-dto": "20.3.0",
|
|
37
|
-
"@shipfox/api-auth-context": "20.
|
|
37
|
+
"@shipfox/api-auth-context": "20.4.0",
|
|
38
38
|
"@shipfox/api-definitions-dto": "20.3.0",
|
|
39
39
|
"@shipfox/api-projects-dto": "20.0.0",
|
|
40
40
|
"@shipfox/api-triggers-dto": "19.0.0",
|
|
41
|
-
"@shipfox/api-workflows-dto": "20.
|
|
41
|
+
"@shipfox/api-workflows-dto": "20.4.0",
|
|
42
42
|
"@shipfox/inter-module": "0.2.3",
|
|
43
43
|
"@shipfox/node-drizzle": "0.3.5",
|
|
44
44
|
"@shipfox/node-error-monitoring": "0.3.0",
|
|
@@ -25,7 +25,7 @@ const context: AgentAccessContext = {
|
|
|
25
25
|
userId: uuid(7),
|
|
26
26
|
workspaceId,
|
|
27
27
|
scopes: ['read'],
|
|
28
|
-
credential: {kind: '
|
|
28
|
+
credential: {kind: 'oauth_grant', grantId: uuid(8), clientId: 'client-1'},
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
describe('paged agent-access tools', () => {
|
|
@@ -26,14 +26,13 @@ describe('agent-access rate limiter', () => {
|
|
|
26
26
|
expect(limiter.consume(oauthCredential)).toEqual({allowed: true});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
test('
|
|
29
|
+
test('prunes expired OAuth grant buckets', () => {
|
|
30
30
|
let now = 5_000;
|
|
31
31
|
const limiter = createAgentAccessRateLimiter({now: () => now, limit: 1});
|
|
32
|
-
const patCredential: AgentAccessCredential = {kind: 'pat', patId: 'pat-1'};
|
|
33
32
|
|
|
34
33
|
expect(limiter.check(oauthCredential)).toEqual({allowed: true});
|
|
35
34
|
expect(limiter.size()).toBe(0);
|
|
36
|
-
expect(limiter.consume(
|
|
35
|
+
expect(limiter.consume(oauthCredential)).toEqual({allowed: true});
|
|
37
36
|
expect(limiter.size()).toBe(1);
|
|
38
37
|
|
|
39
38
|
now += AGENT_ACCESS_TOOL_CALL_WINDOW_MS;
|
package/src/core/rate-limiter.ts
CHANGED
|
@@ -89,7 +89,5 @@ export function createAgentAccessRateLimiter(
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function credentialKey(credential: AgentAccessCredential): string {
|
|
92
|
-
return credential.
|
|
93
|
-
? `oauth_grant:${credential.grantId}`
|
|
94
|
-
: `pat:${credential.patId}`;
|
|
92
|
+
return `oauth_grant:${credential.grantId}`;
|
|
95
93
|
}
|
package/src/core/tools.test.ts
CHANGED
|
@@ -6,7 +6,7 @@ const context: AgentAccessContext = {
|
|
|
6
6
|
userId: 'user-1',
|
|
7
7
|
workspaceId: 'workspace-1',
|
|
8
8
|
scopes: ['read'],
|
|
9
|
-
credential: {kind: '
|
|
9
|
+
credential: {kind: 'oauth_grant', grantId: 'grant-1', clientId: 'client-1'},
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
describe('agent-access fixture tool', () => {
|
|
@@ -5,11 +5,11 @@ const baseContext: AgentAccessContext = {
|
|
|
5
5
|
userId: 'user-1',
|
|
6
6
|
workspaceId: 'workspace-1',
|
|
7
7
|
scopes: ['read'],
|
|
8
|
-
credential: {kind: '
|
|
8
|
+
credential: {kind: 'oauth_grant', grantId: 'grant-1', clientId: 'client-1'},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
describe('agent-access tool call audit recorder', () => {
|
|
12
|
-
test('records bounded identity fields
|
|
12
|
+
test('records bounded OAuth identity fields without tool arguments', () => {
|
|
13
13
|
const recordMetric = vi.fn();
|
|
14
14
|
const logInfo = vi.fn();
|
|
15
15
|
const recorder = createAgentAccessToolCallRecorder({recordMetric, logInfo});
|
|
@@ -32,16 +32,16 @@ describe('agent-access tool call audit recorder', () => {
|
|
|
32
32
|
errorCode: 'none',
|
|
33
33
|
userId: 'user-1',
|
|
34
34
|
workspaceId: 'workspace-1',
|
|
35
|
-
credentialKind: '
|
|
36
|
-
credentialId: '
|
|
37
|
-
clientId:
|
|
35
|
+
credentialKind: 'oauth_grant',
|
|
36
|
+
credentialId: 'grant-1',
|
|
37
|
+
clientId: 'client-1',
|
|
38
38
|
},
|
|
39
39
|
'agent access tool call audited',
|
|
40
40
|
);
|
|
41
41
|
expect(logInfo.mock.calls[0]?.[0]).not.toHaveProperty('arguments');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
test('
|
|
44
|
+
test('keeps the OAuth grant identity explicit', () => {
|
|
45
45
|
const logInfo = vi.fn();
|
|
46
46
|
const recorder = createAgentAccessToolCallRecorder({logInfo, recordMetric: vi.fn()});
|
|
47
47
|
|
|
@@ -49,10 +49,7 @@ describe('agent-access tool call audit recorder', () => {
|
|
|
49
49
|
tool: 'agent_access_fixture',
|
|
50
50
|
outcome: 'tool-error',
|
|
51
51
|
errorCode: 'invalid-request',
|
|
52
|
-
context:
|
|
53
|
-
...baseContext,
|
|
54
|
-
credential: {kind: 'oauth_grant', grantId: 'grant-1', clientId: 'client-1'},
|
|
55
|
-
},
|
|
52
|
+
context: baseContext,
|
|
56
53
|
});
|
|
57
54
|
|
|
58
55
|
expect(logInfo).toHaveBeenCalledWith(
|
|
@@ -39,7 +39,7 @@ function auditLogContext(record: AgentAccessToolCallAuditRecord): Record<string,
|
|
|
39
39
|
userId: record.context.userId,
|
|
40
40
|
workspaceId: record.context.workspaceId,
|
|
41
41
|
credentialKind: credential.kind,
|
|
42
|
-
credentialId: credential.
|
|
43
|
-
clientId: credential.
|
|
42
|
+
credentialId: credential.grantId,
|
|
43
|
+
clientId: credential.clientId,
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -19,7 +19,7 @@ const context: AgentAccessContext = {
|
|
|
19
19
|
userId: 'user-1',
|
|
20
20
|
workspaceId: 'workspace-1',
|
|
21
21
|
scopes: ['read'],
|
|
22
|
-
credential: {kind: '
|
|
22
|
+
credential: {kind: 'oauth_grant', grantId: 'grant-1', clientId: 'client-1'},
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
describe('buildAgentAccessMcpServer', () => {
|