@jini-ai/core 0.6.23 → 0.7.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/CHANGELOG.md +20 -0
- package/dist/approval.d.ts +34 -3
- package/dist/approval.js +27 -4
- package/dist/batch-tool-inputs.d.ts +13 -0
- package/dist/batch-tool-inputs.js +37 -6
- package/dist/contracts/cards.d.ts +382 -0
- package/dist/contracts/cards.js +2 -0
- package/dist/contracts/content-types.d.ts +32 -0
- package/dist/contracts/content-types.js +3 -0
- package/dist/contracts/credentials.d.ts +402 -0
- package/dist/contracts/credentials.js +2 -0
- package/dist/contracts/hosted-mcp/config.d.ts +253 -0
- package/dist/contracts/hosted-mcp/config.js +2 -0
- package/dist/contracts/hosted-mcp/record.d.ts +198 -0
- package/dist/contracts/hosted-mcp/record.js +2 -0
- package/dist/contracts/hosted-mcp/vocabulary.d.ts +14 -0
- package/dist/contracts/hosted-mcp/vocabulary.js +2 -0
- package/dist/contracts/hosted-mcp.d.ts +5 -0
- package/dist/contracts/hosted-mcp.js +2 -0
- package/dist/contracts/mail/adapter-module.d.ts +31 -0
- package/dist/contracts/mail/adapter-module.js +2 -0
- package/dist/contracts/mail/engine-contracts.d.ts +130 -0
- package/dist/contracts/mail/engine-contracts.js +2 -0
- package/dist/contracts/mail/ports.d.ts +93 -0
- package/dist/contracts/mail/ports.js +3 -0
- package/dist/contracts/mail/provider.d.ts +84 -0
- package/dist/contracts/mail/provider.js +2 -0
- package/dist/contracts/mail.d.ts +128 -0
- package/dist/contracts/mail.js +3 -0
- package/dist/contracts/oauth/details.d.ts +46 -0
- package/dist/contracts/oauth/details.js +2 -0
- package/dist/contracts/oauth/flow.d.ts +253 -0
- package/dist/contracts/oauth/flow.js +2 -0
- package/dist/contracts/oauth.d.ts +139 -0
- package/dist/contracts/oauth.js +2 -0
- package/dist/contracts/vault/ports.d.ts +34 -0
- package/dist/contracts/vault/ports.js +2 -0
- package/dist/contracts/vault/records.d.ts +149 -0
- package/dist/contracts/vault/records.js +2 -0
- package/dist/contracts/vault/vendor-credential-sets.d.ts +75 -0
- package/dist/contracts/vault/vendor-credential-sets.js +7 -0
- package/dist/contracts/vault.d.ts +14 -0
- package/dist/contracts/vault.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/primitives/http.d.ts +2 -0
- package/dist/settings/agent-value-write-tools.d.ts +3 -1
- package/dist/settings/agent-value-write-tools.js +11 -4
- package/dist/settings/tool-registrations.js +1 -1
- package/dist/surface-cards.d.ts +2 -0
- package/dist/surface-cards.js +2 -0
- package/dist/text/descriptor-i18n.d.ts +24 -0
- package/dist/text/descriptor-i18n.js +65 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.js +1 -0
- package/dist/tool-metadata-types.d.ts +6 -0
- package/dist/user-facing-error.d.ts +28 -1
- package/dist/user-facing-error.js +87 -4
- package/package.json +44 -2
|
@@ -9,6 +9,12 @@ export interface ToolApprovalMetadata {
|
|
|
9
9
|
export interface ToolMetadata<A extends ToolApprovalMetadata = ToolApprovalMetadata> {
|
|
10
10
|
/** Human-facing action name and optional button verb; presentation only, never authority. */
|
|
11
11
|
readonly title?: string;
|
|
12
|
+
/** Public federation provenance only; credentials, complete URLs and command arguments are excluded. */
|
|
13
|
+
readonly mcpSource?: {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly host: string;
|
|
16
|
+
readonly pluginId?: string;
|
|
17
|
+
};
|
|
12
18
|
/** Plain-language consequence shown before approval; never used to classify or authorize. */
|
|
13
19
|
readonly summary?: string;
|
|
14
20
|
readonly actionVerb?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SecretRedactionOptions } from './redact.js';
|
|
2
|
-
/** Sanitized explanation and copyable evidence. Missing boundary metadata
|
|
2
|
+
/** Sanitized explanation and copyable evidence. Missing boundary metadata is omitted from the copyable evidence. */
|
|
3
3
|
export interface UserFacingError {
|
|
4
4
|
readonly message: string;
|
|
5
5
|
readonly action: string;
|
|
@@ -24,6 +24,7 @@ export interface UserFacingErrorOptions extends SecretRedactionOptions {
|
|
|
24
24
|
* Redacts complete fields before bounding them; uses an existing ERR ID before a boundary fallback.
|
|
25
25
|
* No I/O, logging, clock, randomness or input mutation. Core handles hostile/circular causes.
|
|
26
26
|
* @complexity O(n) diagnostic serialization plus core redaction over all input characters; bounded output.
|
|
27
|
+
* @overallScore 98 — callers own disclosure; public ID shapes do not override credential or exact-secret rules.
|
|
27
28
|
*/
|
|
28
29
|
export declare function formatUserFacingError(requiredArgs: {
|
|
29
30
|
message: string;
|
|
@@ -31,4 +32,30 @@ export declare function formatUserFacingError(requiredArgs: {
|
|
|
31
32
|
step: string;
|
|
32
33
|
cause: unknown;
|
|
33
34
|
}, optionalArgs?: UserFacingErrorOptions): UserFacingError;
|
|
35
|
+
/** Approved host vocabulary only. Keys are static route segments or slash-delimited operation suffixes; prefix an override key with an HTTP method and a space to restrict it. */
|
|
36
|
+
export interface RequestFailureVocabulary {
|
|
37
|
+
readonly nouns: Readonly<Record<string, {
|
|
38
|
+
readonly singular: string;
|
|
39
|
+
readonly plural: string;
|
|
40
|
+
}>>;
|
|
41
|
+
readonly operations?: Readonly<Record<string, RequestFailureDescription>>;
|
|
42
|
+
}
|
|
43
|
+
export interface RequestFailureDescription {
|
|
44
|
+
readonly message: string;
|
|
45
|
+
readonly action: string;
|
|
46
|
+
readonly step: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Describe a failed request using only host-approved words; path values and query strings never render.
|
|
50
|
+
* A registered template is preferred; operation identifiers are the fallback for non-HTTP mappers.
|
|
51
|
+
* This is pure and does not infer a cause, retry a write or assume POST means creation.
|
|
52
|
+
* @complexity O(n + k*n) time for n bounded route tokens and k host override suffixes; O(n) space.
|
|
53
|
+
* @overallScore 98 — the host owns vocabulary accuracy; unknown contexts retain a safe request fallback.
|
|
54
|
+
*/
|
|
55
|
+
export declare function describeRequestFailure({ method, route, operation, vocabulary }: {
|
|
56
|
+
method?: string;
|
|
57
|
+
route?: string;
|
|
58
|
+
operation?: string;
|
|
59
|
+
vocabulary: RequestFailureVocabulary;
|
|
60
|
+
}, _optionalArgs?: Record<string, never>): RequestFailureDescription;
|
|
34
61
|
//# sourceMappingURL=user-facing-error.d.ts.map
|
|
@@ -5,6 +5,7 @@ import { formatErrorForLog, redactSecrets } from './redact.js';
|
|
|
5
5
|
* Redacts complete fields before bounding them; uses an existing ERR ID before a boundary fallback.
|
|
6
6
|
* No I/O, logging, clock, randomness or input mutation. Core handles hostile/circular causes.
|
|
7
7
|
* @complexity O(n) diagnostic serialization plus core redaction over all input characters; bounded output.
|
|
8
|
+
* @overallScore 98 — callers own disclosure; public ID shapes do not override credential or exact-secret rules.
|
|
8
9
|
*/
|
|
9
10
|
export function formatUserFacingError(requiredArgs, optionalArgs = {}) {
|
|
10
11
|
const diagnostic = formatErrorForLog({ error: requiredArgs.cause }, optionalArgs);
|
|
@@ -19,19 +20,31 @@ export function formatUserFacingError(requiredArgs, optionalArgs = {}) {
|
|
|
19
20
|
message: safeField({ text: requiredArgs.message }, optionalArgs),
|
|
20
21
|
action: safeField({ text: requiredArgs.action }, optionalArgs),
|
|
21
22
|
step: safeField({ text: requiredArgs.step }, optionalArgs),
|
|
22
|
-
cause: bound({ text: diagnostic, limit: 4096 }),
|
|
23
|
+
cause: bound({ text: redactSecrets({ input: diagnostic }, optionalArgs), limit: 4096 }),
|
|
23
24
|
...Object.fromEntries(Object.entries(metadata).filter((entry) => entry[1] !== undefined)
|
|
24
|
-
.map(([key, text]) => [key,
|
|
25
|
+
.map(([key, text]) => [key, safeMetadataField({ key, text }, optionalArgs)])),
|
|
25
26
|
};
|
|
26
27
|
const labels = [
|
|
27
28
|
['Message', fields.message], ['Next action', fields.action], ['Error ID', fields.errorId],
|
|
28
29
|
['Step', fields.step], ['Cause', fields.cause], ['App version', fields.appVersion],
|
|
29
30
|
['Jini version', fields.jiniVersion], ['Time', fields.time],
|
|
30
31
|
];
|
|
31
|
-
//
|
|
32
|
-
|
|
32
|
+
// Each field is already PII-scrubbed. Repeat credential/exact redaction across labels,
|
|
33
|
+
// without letting a numeric group in a public correlation ID be mistaken for a card.
|
|
34
|
+
const copyText = bound({ text: redactSecrets({ input: labels.filter(([, value]) => value?.trim()).map(([label, value]) => `${label}: ${value}`).join('\n') }, { ...optionalArgs, redactPii: false }), limit: 8192 });
|
|
33
35
|
return { ...fields, copyText };
|
|
34
36
|
}
|
|
37
|
+
/** Boundary-owned UUIDs are public identifiers, while explicit secret rules still win.
|
|
38
|
+
* Other metadata retains the usual PII policy; arbitrary numeric error IDs remain redactable.
|
|
39
|
+
* @complexity O(n) for redaction of one metadata field; UUID-shape matching is bounded.
|
|
40
|
+
* @overallScore 98 — the boundary owns whether an identifier is a public correlation reference.
|
|
41
|
+
*/
|
|
42
|
+
function safeMetadataField({ key, text }, options) {
|
|
43
|
+
const correlationId = /^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(text);
|
|
44
|
+
if (key === 'errorId' && correlationId)
|
|
45
|
+
return safeField({ text }, { ...options, redactPii: false });
|
|
46
|
+
return safeField({ text }, options);
|
|
47
|
+
}
|
|
35
48
|
/** Redact the complete value so a credential crossing the display bound cannot leak its prefix. */
|
|
36
49
|
function safeField({ text }, options) {
|
|
37
50
|
return bound({ text: redactSecrets({ input: text }, options), limit: 512 });
|
|
@@ -39,4 +52,74 @@ function safeField({ text }, options) {
|
|
|
39
52
|
function bound({ text, limit }) {
|
|
40
53
|
return text.length > limit ? text.slice(0, limit - 1) + '…' : text;
|
|
41
54
|
}
|
|
55
|
+
const REPORT_REQUEST_FAILURE = 'Copy details and report this problem.';
|
|
56
|
+
const REQUEST_ACTIONS = {
|
|
57
|
+
publish: 'publishing', unpublish: 'unpublishing', import: 'import', export: 'export',
|
|
58
|
+
upload: 'upload', download: 'download', restore: 'restore', send: 'send', undo: 'undo',
|
|
59
|
+
pull: 'pull', push: 'push', plan: 'preparation', confirm: 'confirmation', execute: 'execution',
|
|
60
|
+
update: 'save', save: 'save', create: 'creation', delete: 'removal',
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Describe a failed request using only host-approved words; path values and query strings never render.
|
|
64
|
+
* A registered template is preferred; operation identifiers are the fallback for non-HTTP mappers.
|
|
65
|
+
* This is pure and does not infer a cause, retry a write or assume POST means creation.
|
|
66
|
+
* @complexity O(n + k*n) time for n bounded route tokens and k host override suffixes; O(n) space.
|
|
67
|
+
* @overallScore 98 — the host owns vocabulary accuracy; unknown contexts retain a safe request fallback.
|
|
68
|
+
*/
|
|
69
|
+
export function describeRequestFailure({ method, route, operation, vocabulary }, _optionalArgs = {}) {
|
|
70
|
+
const tokens = (route || operation || '').slice(0, 2048).split(/[?#]/, 1)[0].split('/').slice(0, 64);
|
|
71
|
+
const override = Object.entries(vocabulary.operations ?? {}).find(([suffix]) => matchesRequestSuffix(tokens, suffix, method?.toUpperCase()));
|
|
72
|
+
if (override)
|
|
73
|
+
return { ...override[1] };
|
|
74
|
+
const nounKey = tokens.slice().reverse().find(token => Object.hasOwn(vocabulary.nouns, token));
|
|
75
|
+
const noun = nounKey === undefined ? undefined : vocabulary.nouns[nounKey];
|
|
76
|
+
const actionToken = tokens[tokens.length - 1] ?? '';
|
|
77
|
+
const action = Object.hasOwn(REQUEST_ACTIONS, actionToken) ? REQUEST_ACTIONS[actionToken] : undefined;
|
|
78
|
+
return requestFailureDescription({ method: method?.toUpperCase(), noun, action });
|
|
79
|
+
}
|
|
80
|
+
function matchesRequestSuffix(tokens, suffix, method) {
|
|
81
|
+
const [prefix, path] = suffix.split(' ', 2);
|
|
82
|
+
if (path !== undefined && prefix !== method)
|
|
83
|
+
return false;
|
|
84
|
+
const expected = (path ?? prefix).split('/');
|
|
85
|
+
return expected.every((token, index) => token === tokens[tokens.length - expected.length + index]);
|
|
86
|
+
}
|
|
87
|
+
/** Keep uncertain writes explicit: users check the result before repeating an operation. */
|
|
88
|
+
function requestFailureDescription({ method, noun, action }) {
|
|
89
|
+
if (method === 'GET' || method === 'HEAD')
|
|
90
|
+
return readFailureDescription(noun);
|
|
91
|
+
if (method === 'PUT' || method === 'PATCH' || action === 'save')
|
|
92
|
+
return saveFailureDescription(noun);
|
|
93
|
+
if (method === 'DELETE' || action === 'removal')
|
|
94
|
+
return removalFailureDescription(noun);
|
|
95
|
+
return operationFailureDescription(noun, action);
|
|
96
|
+
}
|
|
97
|
+
function operationFailureDescription(noun, action) {
|
|
98
|
+
return {
|
|
99
|
+
message: noun ? `The ${noun.singular} ${action ?? 'operation'} could not be completed.` : 'The request could not be completed.',
|
|
100
|
+
action: `Check the result before repeating this operation. ${REPORT_REQUEST_FAILURE}`,
|
|
101
|
+
step: noun ? `${noun.singular} ${action ?? 'operation'}` : 'Request',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function readFailureDescription(noun) {
|
|
105
|
+
return {
|
|
106
|
+
message: `The ${noun?.plural ?? 'requested information'} could not be loaded.`,
|
|
107
|
+
action: 'Try loading them again. If it still fails, copy details and report this problem.',
|
|
108
|
+
step: `Load ${noun?.plural ?? 'information'}`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function saveFailureDescription(noun) {
|
|
112
|
+
return {
|
|
113
|
+
message: `The ${noun?.singular ?? 'requested'} save could not be completed.`,
|
|
114
|
+
action: `Check whether your changes were saved before repeating the save. ${REPORT_REQUEST_FAILURE}`,
|
|
115
|
+
step: `Save ${noun?.singular ?? 'changes'}`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function removalFailureDescription(noun) {
|
|
119
|
+
return {
|
|
120
|
+
message: `The ${noun?.singular ?? 'item'} removal could not be confirmed.`,
|
|
121
|
+
action: `Check the list before repeating the removal. ${REPORT_REQUEST_FAILURE}`,
|
|
122
|
+
step: `Remove ${noun?.singular ?? 'item'}`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
42
125
|
//# sourceMappingURL=user-facing-error.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The Jini kernel: typed DI tokens, pack composition and lifecycle, the tool registry, redaction, and origin/API-token auth primitives. Zero dependencies.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,14 @@
|
|
|
29
29
|
"./settings/express": "node",
|
|
30
30
|
"./plugin-directory": "universal",
|
|
31
31
|
"./filesystem": "universal",
|
|
32
|
-
"./optional-peer": "universal"
|
|
32
|
+
"./optional-peer": "universal",
|
|
33
|
+
"./contracts/cards": "universal",
|
|
34
|
+
"./contracts/credentials": "universal",
|
|
35
|
+
"./contracts/mail": "universal",
|
|
36
|
+
"./contracts/vault": "universal",
|
|
37
|
+
"./contracts/oauth": "universal",
|
|
38
|
+
"./contracts/content-types": "universal",
|
|
39
|
+
"./contracts/hosted-mcp": "universal"
|
|
33
40
|
},
|
|
34
41
|
"isolation": {
|
|
35
42
|
"entries": {
|
|
@@ -167,6 +174,41 @@
|
|
|
167
174
|
"types": "./dist/optional-peer.d.ts",
|
|
168
175
|
"import": "./dist/optional-peer.js",
|
|
169
176
|
"default": "./dist/optional-peer.js"
|
|
177
|
+
},
|
|
178
|
+
"./contracts/cards": {
|
|
179
|
+
"types": "./dist/contracts/cards.d.ts",
|
|
180
|
+
"import": "./dist/contracts/cards.js",
|
|
181
|
+
"default": "./dist/contracts/cards.js"
|
|
182
|
+
},
|
|
183
|
+
"./contracts/credentials": {
|
|
184
|
+
"types": "./dist/contracts/credentials.d.ts",
|
|
185
|
+
"import": "./dist/contracts/credentials.js",
|
|
186
|
+
"default": "./dist/contracts/credentials.js"
|
|
187
|
+
},
|
|
188
|
+
"./contracts/mail": {
|
|
189
|
+
"types": "./dist/contracts/mail.d.ts",
|
|
190
|
+
"import": "./dist/contracts/mail.js",
|
|
191
|
+
"default": "./dist/contracts/mail.js"
|
|
192
|
+
},
|
|
193
|
+
"./contracts/vault": {
|
|
194
|
+
"types": "./dist/contracts/vault.d.ts",
|
|
195
|
+
"import": "./dist/contracts/vault.js",
|
|
196
|
+
"default": "./dist/contracts/vault.js"
|
|
197
|
+
},
|
|
198
|
+
"./contracts/oauth": {
|
|
199
|
+
"types": "./dist/contracts/oauth.d.ts",
|
|
200
|
+
"import": "./dist/contracts/oauth.js",
|
|
201
|
+
"default": "./dist/contracts/oauth.js"
|
|
202
|
+
},
|
|
203
|
+
"./contracts/content-types": {
|
|
204
|
+
"types": "./dist/contracts/content-types.d.ts",
|
|
205
|
+
"import": "./dist/contracts/content-types.js",
|
|
206
|
+
"default": "./dist/contracts/content-types.js"
|
|
207
|
+
},
|
|
208
|
+
"./contracts/hosted-mcp": {
|
|
209
|
+
"types": "./dist/contracts/hosted-mcp.d.ts",
|
|
210
|
+
"import": "./dist/contracts/hosted-mcp.js",
|
|
211
|
+
"default": "./dist/contracts/hosted-mcp.js"
|
|
170
212
|
}
|
|
171
213
|
},
|
|
172
214
|
"files": [
|