@jini-ai/core 0.7.3-next.1 → 0.7.3-next.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.
- package/CHANGELOG.md +2 -0
- package/dist/contracts/observability.d.ts +3 -0
- package/dist/contracts/observability.js +1 -0
- package/dist/gated-mutations/gateway.d.ts +2 -0
- package/dist/gated-mutations/gateway.js +4 -1
- package/package.json +2 -2
- package/plugin-directory.d.ts +2 -2
- package/plugin-directory.js +16 -10
package/CHANGELOG.md
CHANGED
|
@@ -63,6 +63,7 @@ export interface AgentRunTrackingInput {
|
|
|
63
63
|
export interface AgentRunTrackingOptions {
|
|
64
64
|
conversationId?: string;
|
|
65
65
|
agentName?: string;
|
|
66
|
+
traceparent?: string;
|
|
66
67
|
}
|
|
67
68
|
/** `interrupted`: the run vanished (its process restarted). `abandoned`: the watcher gave up unproven. */
|
|
68
69
|
export type AgentRunStatus = 'succeeded' | 'failed' | 'canceled' | 'interrupted' | 'abandoned';
|
|
@@ -83,6 +84,7 @@ export type OperationAttributes = Readonly<Record<string, string | number>>;
|
|
|
83
84
|
export interface OperationTrackingInput {
|
|
84
85
|
name: string;
|
|
85
86
|
attributes?: OperationAttributes;
|
|
87
|
+
traceparent?: string;
|
|
86
88
|
}
|
|
87
89
|
/** `outcome` is the feature's own fixed label (`completed`, `denied`, `timed-out`); `failed` says
|
|
88
90
|
* whether that outcome is a failure, which only the feature can judge (a denial is not one). */
|
|
@@ -131,6 +133,7 @@ export interface MetricOptions {
|
|
|
131
133
|
export interface ObservabilityPort {
|
|
132
134
|
/** Current structural tracing scope, absent outside a trace. Never generates an ID. */
|
|
133
135
|
activeTraceIds?(required?: Record<string, never>, optional?: Record<string, never>): TraceIds | undefined;
|
|
136
|
+
activeTraceparent?(): string | undefined;
|
|
134
137
|
/** Explicit capability: a callable noop metric does not imply local metric admission. */
|
|
135
138
|
readonly supportsMetric?: boolean;
|
|
136
139
|
/** Records one measurement; adapters without a metrics backend use a no-op. */
|
|
@@ -7,6 +7,7 @@ const NOOP_SIGNAL_TRACKER = Object.freeze({ end() { }, run });
|
|
|
7
7
|
const NOOP_PORT = Object.freeze({
|
|
8
8
|
supportsMetric: false,
|
|
9
9
|
activeTraceIds: () => undefined,
|
|
10
|
+
activeTraceparent: () => undefined,
|
|
10
11
|
trackRequest: () => NOOP_TRACKER,
|
|
11
12
|
trackDbQuery: () => NOOP_SIGNAL_TRACKER,
|
|
12
13
|
trackOutboundCall: () => NOOP_SIGNAL_TRACKER,
|
|
@@ -99,6 +99,7 @@ export declare function confirm(required: {
|
|
|
99
99
|
hooks: GatedMutationHooks<unknown, unknown>;
|
|
100
100
|
planId: string;
|
|
101
101
|
planHash: string;
|
|
102
|
+
signal?: AbortSignal;
|
|
102
103
|
}, _optional?: Record<string, never>): Promise<ConfirmationTokenRecord>;
|
|
103
104
|
/**
|
|
104
105
|
* Rejection precedence is binding when failures co-occur: fresh authorization, token state,
|
|
@@ -112,5 +113,6 @@ export declare function execute<TResult>(required: {
|
|
|
112
113
|
principalKind: PrincipalKind;
|
|
113
114
|
hooks: GatedMutationHooks<unknown, TResult>;
|
|
114
115
|
confirmationToken: string;
|
|
116
|
+
signal?: AbortSignal;
|
|
115
117
|
}, _optional?: Record<string, never>): Promise<TResult>;
|
|
116
118
|
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -91,6 +91,7 @@ export async function confirm(required, _optional = {}) {
|
|
|
91
91
|
generateToken: deps.generateToken,
|
|
92
92
|
ttlSeconds: deps.ttlSeconds,
|
|
93
93
|
});
|
|
94
|
+
required.signal?.throwIfAborted();
|
|
94
95
|
await deps.tokens.save({ record: token });
|
|
95
96
|
return token;
|
|
96
97
|
}
|
|
@@ -121,7 +122,9 @@ export async function execute(required, _optional = {}) {
|
|
|
121
122
|
}
|
|
122
123
|
// Concurrent executions can pass every earlier check; atomic redemption makes the loser fail
|
|
123
124
|
// before its domain mutation, preventing a second application of the same approval.
|
|
124
|
-
const
|
|
125
|
+
const now = nowIso({ clock: deps.clock });
|
|
126
|
+
required.signal?.throwIfAborted();
|
|
127
|
+
const { redeemed, record: latestRecord } = await deps.tokens.tryRedeem({ token: confirmationToken, now });
|
|
125
128
|
if (!redeemed)
|
|
126
129
|
throw unredeemableTokenError(latestRecord);
|
|
127
130
|
return hooks.executeMutation({ planHash, details });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/core",
|
|
3
|
-
"version": "0.7.3-next.
|
|
3
|
+
"version": "0.7.3-next.2",
|
|
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": {
|
|
@@ -458,7 +458,7 @@
|
|
|
458
458
|
"registry": "https://registry.npmjs.org"
|
|
459
459
|
},
|
|
460
460
|
"devDependencies": {
|
|
461
|
-
"@vitest/coverage-v8": "^2.
|
|
461
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
462
462
|
"express": "^4.21.0",
|
|
463
463
|
"@types/express": "^4.17.21"
|
|
464
464
|
},
|
package/plugin-directory.d.ts
CHANGED
|
@@ -27,6 +27,6 @@ export interface PluginLookupPort {
|
|
|
27
27
|
export type PluginIdentityCandidate = Pick<PluginProvider, 'id' | 'family' | 'localId'>;
|
|
28
28
|
export function assertPluginIdentityAvailable(required: { readonly candidate: PluginIdentityCandidate; readonly installed: readonly PluginProvider[] }, optional?: Record<string, never>): void;
|
|
29
29
|
export function createPluginLookupFacade(required: { readonly lookup: PluginLookupPort }, optional?: Record<string, never>): PluginLookupPort;
|
|
30
|
-
export function validatePluginIdentity(required: { readonly manifest: unknown; readonly namespace: string }, optional?: Record<string, never>): { readonly errors: readonly string[] };
|
|
31
|
-
export function readPluginIdentity(required: { readonly manifest: Readonly<Record<string, unknown>>; readonly namespace: string; readonly name?: string }, optional?: Record<string, never>): PluginIdentity;
|
|
30
|
+
export function validatePluginIdentity(required: { readonly manifest: unknown; readonly namespace: string; readonly legacyNamespace?: string | undefined }, optional?: Record<string, never>): { readonly errors: readonly string[] };
|
|
31
|
+
export function readPluginIdentity(required: { readonly manifest: Readonly<Record<string, unknown>>; readonly namespace: string; readonly name?: string; readonly legacyNamespace?: string | undefined }, optional?: Record<string, never>): PluginIdentity;
|
|
32
32
|
export function createPluginLookup(required: { readonly listPlugins: (required: Record<string, never>, optional?: Record<string, never>) => Promise<readonly PluginProvider[]> }, optional?: { readonly warn?: (message: string) => void }): PluginLookupPort;
|
package/plugin-directory.js
CHANGED
|
@@ -13,11 +13,17 @@ const malformedId = id => typeof id !== 'string' || id.length > 129 || !ID_PATTE
|
|
|
13
13
|
const validCapability = p => typeof p === 'string' && p.length <= 129 && CAPABILITY_PATTERN.test(p);
|
|
14
14
|
const legacyIdFor = localName => `unknown/${localName}`;
|
|
15
15
|
|
|
16
|
+
function readIdentityExtension({ manifest, namespace, legacyNamespace }) {
|
|
17
|
+
const extension = manifest?.extensions?.[namespace];
|
|
18
|
+
if (extension === undefined && legacyNamespace !== undefined) return manifest?.extensions?.[legacyNamespace];
|
|
19
|
+
return extension;
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
/** The first shape error that stops identity validation before any field is interpreted. */
|
|
17
|
-
function structuralError({ manifest, namespace }) {
|
|
23
|
+
function structuralError({ manifest, namespace, legacyNamespace }) {
|
|
18
24
|
if (!object(manifest)) return 'Plugin manifest must be an object.';
|
|
19
25
|
if (manifest.extensions !== undefined && !object(manifest.extensions)) return 'Plugin extensions must be an object.';
|
|
20
|
-
const extension = manifest
|
|
26
|
+
const extension = readIdentityExtension({ manifest, namespace, legacyNamespace });
|
|
21
27
|
if (extension !== undefined && !object(extension)) return 'Plugin identity extension must be an object.';
|
|
22
28
|
return undefined;
|
|
23
29
|
}
|
|
@@ -37,31 +43,31 @@ function providesErrors({ provides }) {
|
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
/** Collects identity errors without mutating the portable manifest. Absent metadata is legacy.
|
|
40
|
-
* @param {{manifest: unknown, namespace: string}} required
|
|
46
|
+
* @param {{manifest: unknown, namespace: string, legacyNamespace?: string | undefined}} required
|
|
41
47
|
* @param {Record<string, never>} [optional]
|
|
42
48
|
* @returns {{errors: string[]}}
|
|
43
49
|
* @complexity O(k + p) in keyword and provides entries; no I/O.
|
|
44
50
|
*/
|
|
45
|
-
export function validatePluginIdentity({ manifest, namespace }, optional = {}) {
|
|
46
|
-
const structural = structuralError({ manifest, namespace });
|
|
51
|
+
export function validatePluginIdentity({ manifest, namespace, legacyNamespace }, optional = {}) {
|
|
52
|
+
const structural = structuralError({ manifest, namespace, legacyNamespace });
|
|
47
53
|
if (structural !== undefined) return { errors: [structural] };
|
|
48
|
-
const extension = manifest
|
|
54
|
+
const extension = readIdentityExtension({ manifest, namespace, legacyNamespace });
|
|
49
55
|
if (extension === undefined) return { errors: [] };
|
|
50
56
|
return { errors: [...idErrors({ id: extension.id }), ...providesErrors({ provides: extension.provides })] };
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
/** Resolves one identity; warns on missing ids and refuses malformed declarations.
|
|
54
|
-
* @param {{manifest: Record<string, unknown>, namespace: string, name?: string}} required
|
|
60
|
+
* @param {{manifest: Record<string, unknown>, namespace: string, name?: string, legacyNamespace?: string | undefined}} required
|
|
55
61
|
* @param {Record<string, never>} [optional]
|
|
56
62
|
* @returns {{id: string, keywords: string[], provides: string[], warnings: string[]}}
|
|
57
63
|
* @throws {TypeError} Malformed identity metadata or missing legacy name.
|
|
58
64
|
* @example readPluginIdentity({ manifest: { name: 'example' }, namespace: 'host' })
|
|
59
65
|
* @complexity O(k + p), copying arrays so a caller cannot mutate manifest metadata.
|
|
60
66
|
*/
|
|
61
|
-
export function readPluginIdentity({ manifest, namespace, name }, optional = {}) {
|
|
62
|
-
const { errors } = validatePluginIdentity({ manifest, namespace });
|
|
67
|
+
export function readPluginIdentity({ manifest, namespace, name, legacyNamespace }, optional = {}) {
|
|
68
|
+
const { errors } = validatePluginIdentity({ manifest, namespace, legacyNamespace });
|
|
63
69
|
if (errors.length) throw new TypeError(errors.join(' '));
|
|
64
|
-
const extension = manifest
|
|
70
|
+
const extension = readIdentityExtension({ manifest, namespace, legacyNamespace });
|
|
65
71
|
const declaredId = extension?.id;
|
|
66
72
|
const localName = name ?? manifest.name;
|
|
67
73
|
const id = declaredId ?? legacyIdentity({ localName });
|