@aumos/agent-sense 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.
- package/dist/client.d.ts +118 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +127 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +258 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -0
- package/src/client.ts +321 -0
- package/src/index.ts +37 -0
- package/src/types.ts +315 -0
- package/tsconfig.json +25 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-sense transparency API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentSenseClient } from "@aumos/agent-sense";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentSenseClient({ baseUrl: "http://localhost:8091" });
|
|
12
|
+
*
|
|
13
|
+
* const intent = await client.parseIntent({
|
|
14
|
+
* utterance: "Show me my account balance",
|
|
15
|
+
* session_id: "sess-001",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (intent.ok) {
|
|
19
|
+
* console.log("Parsed intent:", intent.data.intent);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { AccessibilityCheckResult, AccessibilityConfig, ApiResult, DetectedContext, DialogueState, FeedbackEntry, FeedbackSubmitRequest, FeedbackSummary, ResponseCandidate, TransparencyIndicator, UserIntent } from "./types.js";
|
|
24
|
+
/** Configuration options for the AgentSenseClient. */
|
|
25
|
+
export interface AgentSenseClientConfig {
|
|
26
|
+
/** Base URL of the agent-sense server (e.g. "http://localhost:8091"). */
|
|
27
|
+
readonly baseUrl: string;
|
|
28
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
29
|
+
readonly timeoutMs?: number;
|
|
30
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
31
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
32
|
+
}
|
|
33
|
+
/** Typed HTTP client for the agent-sense server. */
|
|
34
|
+
export interface AgentSenseClient {
|
|
35
|
+
/**
|
|
36
|
+
* Parse the intent from a user utterance.
|
|
37
|
+
*
|
|
38
|
+
* @param options - Utterance and optional session context.
|
|
39
|
+
* @returns A UserIntent record with intent label, confidence, and entities.
|
|
40
|
+
*/
|
|
41
|
+
parseIntent(options: {
|
|
42
|
+
utterance: string;
|
|
43
|
+
session_id?: string;
|
|
44
|
+
context?: Readonly<Record<string, unknown>>;
|
|
45
|
+
}): Promise<ApiResult<UserIntent>>;
|
|
46
|
+
/**
|
|
47
|
+
* Rank a list of response candidates for the given context.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Candidates, user text, and optional history.
|
|
50
|
+
* @returns The candidates re-ordered by composite score.
|
|
51
|
+
*/
|
|
52
|
+
rankResponses(options: {
|
|
53
|
+
candidates: readonly {
|
|
54
|
+
candidate_id: string;
|
|
55
|
+
text: string;
|
|
56
|
+
relevance_score: number;
|
|
57
|
+
}[];
|
|
58
|
+
user_text: string;
|
|
59
|
+
history?: readonly string[];
|
|
60
|
+
recent_shown?: readonly string[];
|
|
61
|
+
}): Promise<ApiResult<readonly ResponseCandidate[]>>;
|
|
62
|
+
/**
|
|
63
|
+
* Submit structured feedback for an agent interaction.
|
|
64
|
+
*
|
|
65
|
+
* @param request - Feedback submission payload.
|
|
66
|
+
* @returns The stored FeedbackEntry record.
|
|
67
|
+
*/
|
|
68
|
+
collectFeedback(request: FeedbackSubmitRequest): Promise<ApiResult<FeedbackEntry>>;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve the current dialogue state for a session.
|
|
71
|
+
*
|
|
72
|
+
* @param sessionId - The session identifier.
|
|
73
|
+
* @returns The DialogueState record for this session.
|
|
74
|
+
*/
|
|
75
|
+
getDialogueState(sessionId: string): Promise<ApiResult<DialogueState>>;
|
|
76
|
+
/**
|
|
77
|
+
* Check HTML content for WCAG 2.1 accessibility violations.
|
|
78
|
+
*
|
|
79
|
+
* @param config - Accessibility check configuration including HTML markup.
|
|
80
|
+
* @returns The check result with any violations found.
|
|
81
|
+
*/
|
|
82
|
+
checkAccessibility(config: AccessibilityConfig): Promise<ApiResult<AccessibilityCheckResult>>;
|
|
83
|
+
/**
|
|
84
|
+
* Get the transparency indicator (confidence + disclosure) for an agent.
|
|
85
|
+
*
|
|
86
|
+
* @param options - Agent ID and optional session context.
|
|
87
|
+
* @returns A TransparencyIndicator combining confidence and disclosure.
|
|
88
|
+
*/
|
|
89
|
+
getTransparencyIndicator(options: {
|
|
90
|
+
agent_id: string;
|
|
91
|
+
session_id?: string;
|
|
92
|
+
}): Promise<ApiResult<TransparencyIndicator>>;
|
|
93
|
+
/**
|
|
94
|
+
* Detect the client context from a User-Agent string and HTTP headers.
|
|
95
|
+
*
|
|
96
|
+
* @param options - User-Agent string and optional HTTP hint headers.
|
|
97
|
+
* @returns A DetectedContext with device type, network quality, and capabilities.
|
|
98
|
+
*/
|
|
99
|
+
detectContext(options: {
|
|
100
|
+
user_agent: string;
|
|
101
|
+
headers?: Readonly<Record<string, string>>;
|
|
102
|
+
}): Promise<ApiResult<DetectedContext>>;
|
|
103
|
+
/**
|
|
104
|
+
* Get aggregated feedback summary for an agent.
|
|
105
|
+
*
|
|
106
|
+
* @param agentId - The agent identifier.
|
|
107
|
+
* @returns A FeedbackSummary with satisfaction score and category breakdown.
|
|
108
|
+
*/
|
|
109
|
+
getFeedbackSummary(agentId: string): Promise<ApiResult<FeedbackSummary>>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a typed HTTP client for the agent-sense server.
|
|
113
|
+
*
|
|
114
|
+
* @param config - Client configuration including base URL.
|
|
115
|
+
* @returns An AgentSenseClient instance.
|
|
116
|
+
*/
|
|
117
|
+
export declare function createAgentSenseClient(config: AgentSenseClientConfig): AgentSenseClient;
|
|
118
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EAEnB,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACX,MAAM,YAAY,CAAC;AAMpB,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACrC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AA0DD,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KAC7C,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE;QACrB,UAAU,EAAE,SAAS;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,eAAe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|
+
/**
|
|
2
|
+
* HTTP client for the agent-sense transparency API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentSenseClient } from "@aumos/agent-sense";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentSenseClient({ baseUrl: "http://localhost:8091" });
|
|
12
|
+
*
|
|
13
|
+
* const intent = await client.parseIntent({
|
|
14
|
+
* utterance: "Show me my account balance",
|
|
15
|
+
* session_id: "sess-001",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (intent.ok) {
|
|
19
|
+
* console.log("Parsed intent:", intent.data.intent);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Internal helpers
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
async function fetchJson(url, init, timeoutMs) {
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
const body = await response.json();
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const errorBody = body;
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
error: {
|
|
38
|
+
error: errorBody.error ?? "Unknown error",
|
|
39
|
+
detail: errorBody.detail ?? "",
|
|
40
|
+
},
|
|
41
|
+
status: response.status,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return { ok: true, data: body };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
clearTimeout(timeoutId);
|
|
48
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
error: { error: "Network error", detail: message },
|
|
52
|
+
status: 0,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function buildHeaders(extraHeaders) {
|
|
57
|
+
return {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
Accept: "application/json",
|
|
60
|
+
...extraHeaders,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Client factory
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* Create a typed HTTP client for the agent-sense server.
|
|
68
|
+
*
|
|
69
|
+
* @param config - Client configuration including base URL.
|
|
70
|
+
* @returns An AgentSenseClient instance.
|
|
71
|
+
*/
|
|
72
|
+
export function createAgentSenseClient(config) {
|
|
73
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
74
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
75
|
+
return {
|
|
76
|
+
async parseIntent(options) {
|
|
77
|
+
return fetchJson(`${baseUrl}/sense/intent`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: baseHeaders,
|
|
80
|
+
body: JSON.stringify(options),
|
|
81
|
+
}, timeoutMs);
|
|
82
|
+
},
|
|
83
|
+
async rankResponses(options) {
|
|
84
|
+
return fetchJson(`${baseUrl}/sense/rank`, {
|
|
85
|
+
method: "POST",
|
|
86
|
+
headers: baseHeaders,
|
|
87
|
+
body: JSON.stringify(options),
|
|
88
|
+
}, timeoutMs);
|
|
89
|
+
},
|
|
90
|
+
async collectFeedback(request) {
|
|
91
|
+
return fetchJson(`${baseUrl}/sense/feedback`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: baseHeaders,
|
|
94
|
+
body: JSON.stringify(request),
|
|
95
|
+
}, timeoutMs);
|
|
96
|
+
},
|
|
97
|
+
async getDialogueState(sessionId) {
|
|
98
|
+
return fetchJson(`${baseUrl}/sense/sessions/${encodeURIComponent(sessionId)}/state`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
99
|
+
},
|
|
100
|
+
async checkAccessibility(config) {
|
|
101
|
+
return fetchJson(`${baseUrl}/sense/accessibility/check`, {
|
|
102
|
+
method: "POST",
|
|
103
|
+
headers: baseHeaders,
|
|
104
|
+
body: JSON.stringify(config),
|
|
105
|
+
}, timeoutMs);
|
|
106
|
+
},
|
|
107
|
+
async getTransparencyIndicator(options) {
|
|
108
|
+
const params = new URLSearchParams();
|
|
109
|
+
params.set("agent_id", options.agent_id);
|
|
110
|
+
if (options.session_id !== undefined) {
|
|
111
|
+
params.set("session_id", options.session_id);
|
|
112
|
+
}
|
|
113
|
+
return fetchJson(`${baseUrl}/sense/transparency?${params.toString()}`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
114
|
+
},
|
|
115
|
+
async detectContext(options) {
|
|
116
|
+
return fetchJson(`${baseUrl}/sense/context/detect`, {
|
|
117
|
+
method: "POST",
|
|
118
|
+
headers: baseHeaders,
|
|
119
|
+
body: JSON.stringify(options),
|
|
120
|
+
}, timeoutMs);
|
|
121
|
+
},
|
|
122
|
+
async getFeedbackSummary(agentId) {
|
|
123
|
+
return fetchJson(`${baseUrl}/sense/feedback/${encodeURIComponent(agentId)}/summary`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA+BH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,KAAK,UAAU,SAAS,CACtB,GAAW,EACX,IAAiB,EACjB,SAAiB;IAEjB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAA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AAO,EAAE,WAAW;gBACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aAC7B,EACD,SAAS,CACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,wBAAwB,CAAC,OAG9B;YACC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YACrC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,SAAS,CACd,GAAG,OAAO,uBAAuB,MAAM,CAAC,QAAQ,EAAE,EAAE,EACpD,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EACvC,SAAS,CACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,OAGnB;YACC,OAAO,SAAS,CACd,GAAG,OAAO,uBAAuB,EACjC;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,WAAW;gBACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,EACD,SAAS,CACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,kBAAkB,CAAC,OAAe;YACtC,OAAO,SAAS,CACd,GAAG,OAAO,mBAAmB,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAClE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EACvC,SAAS,CACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-sense
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-sense transparency layer.
|
|
5
|
+
* Provides HTTP client, intent parsing, response ranking, feedback collection,
|
|
6
|
+
* accessibility checking, and confidence/disclosure type definitions.
|
|
7
|
+
*/
|
|
8
|
+
export type { AgentSenseClient, AgentSenseClientConfig } from "./client.js";
|
|
9
|
+
export { createAgentSenseClient } from "./client.js";
|
|
10
|
+
export type { AccessibilityCheckResult, AccessibilityConfig, AIDisclosureCard, ApiError, ApiResult, BrowserCapabilities, ConfidenceIndicator, ConfidenceLevel, DetectedContext, DeviceType, DialogueState, DisclosureLevel, FeedbackCategory, FeedbackEntry, FeedbackSubmitRequest, FeedbackSummary, NetworkQuality, ResponseCandidate, TransparencyIndicator, UserIntent, WCAGLevel, WCAGViolation, } from "./types.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-sense
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-sense transparency layer.
|
|
5
|
+
* Provides HTTP client, intent parsing, response ranking, feedback collection,
|
|
6
|
+
* accessibility checking, and confidence/disclosure type definitions.
|
|
7
|
+
*/
|
|
8
|
+
export { createAgentSenseClient } from "./client.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-sense transparency layer.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python dataclasses and Pydantic models defined in:
|
|
5
|
+
* agent_sense.indicators.confidence (ConfidenceLevel, ConfidenceIndicator)
|
|
6
|
+
* agent_sense.indicators.disclosure (DisclosureLevel, AIDisclosureCard)
|
|
7
|
+
* agent_sense.feedback.collector (FeedbackCategory, FeedbackEntry, FeedbackSummary)
|
|
8
|
+
* agent_sense.context.detector (DeviceType, NetworkQuality, BrowserCapabilities, DetectedContext)
|
|
9
|
+
* agent_sense.accessibility.wcag (WCAGLevel, WCAGViolation)
|
|
10
|
+
* agent_sense.disclosure.transparency (SessionStats)
|
|
11
|
+
*
|
|
12
|
+
* All interfaces use readonly fields to match Python frozen dataclasses.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Five-tier categorical confidence classification.
|
|
16
|
+
* Maps to ConfidenceLevel enum in Python.
|
|
17
|
+
* Score bands: very_low [0,0.2), low [0.2,0.4), medium [0.4,0.6),
|
|
18
|
+
* high [0.6,0.8), very_high [0.8,1.0].
|
|
19
|
+
*/
|
|
20
|
+
export type ConfidenceLevel = "very_low" | "low" | "medium" | "high" | "very_high";
|
|
21
|
+
/** Structured confidence measurement for an AI agent response. */
|
|
22
|
+
export interface ConfidenceIndicator {
|
|
23
|
+
/** Raw numeric confidence in [0.0, 1.0]. */
|
|
24
|
+
readonly score: number;
|
|
25
|
+
/** Categorical tier derived from score. */
|
|
26
|
+
readonly level: ConfidenceLevel;
|
|
27
|
+
/** Human-readable explanation of the confidence assessment. */
|
|
28
|
+
readonly reasoning: string;
|
|
29
|
+
/** Map of contributing factor names to their individual scores [0, 1]. */
|
|
30
|
+
readonly factors: Readonly<Record<string, number>>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Controls the verbosity of disclosure card rendering.
|
|
34
|
+
* Maps to DisclosureLevel enum in Python.
|
|
35
|
+
*/
|
|
36
|
+
export type DisclosureLevel = "minimal" | "standard" | "detailed" | "full";
|
|
37
|
+
/** Immutable disclosure card for an AI agent deployment. */
|
|
38
|
+
export interface AIDisclosureCard {
|
|
39
|
+
/** Human-readable name of the agent. */
|
|
40
|
+
readonly agent_name: string;
|
|
41
|
+
/** Semantic version or build identifier. */
|
|
42
|
+
readonly agent_version: string;
|
|
43
|
+
/** Organisation that produced the underlying model. */
|
|
44
|
+
readonly model_provider: string;
|
|
45
|
+
/** Identifier of the specific model being used. */
|
|
46
|
+
readonly model_name: string;
|
|
47
|
+
/** Ordered list of things this agent can do well. */
|
|
48
|
+
readonly capabilities: readonly string[];
|
|
49
|
+
/** Ordered list of known constraints or failure modes. */
|
|
50
|
+
readonly limitations: readonly string[];
|
|
51
|
+
/** Plain-language description of how conversation data is handled. */
|
|
52
|
+
readonly data_handling: string;
|
|
53
|
+
/** ISO-8601 UTC datetime at which this card was last revised. */
|
|
54
|
+
readonly last_updated: string;
|
|
55
|
+
/** Verbosity level used when rendering this card. */
|
|
56
|
+
readonly disclosure_level: DisclosureLevel;
|
|
57
|
+
}
|
|
58
|
+
/** Full transparency indicator combining confidence and disclosure. */
|
|
59
|
+
export interface TransparencyIndicator {
|
|
60
|
+
/** The confidence measurement for a response. */
|
|
61
|
+
readonly confidence: ConfidenceIndicator;
|
|
62
|
+
/** The AI disclosure card for this deployment. */
|
|
63
|
+
readonly disclosure: AIDisclosureCard;
|
|
64
|
+
/** ISO-8601 UTC timestamp when this indicator was generated. */
|
|
65
|
+
readonly generated_at: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Category labels for user feedback.
|
|
69
|
+
* Maps to FeedbackCategory enum in Python.
|
|
70
|
+
*/
|
|
71
|
+
export type FeedbackCategory = "helpful" | "unhelpful" | "harmful" | "irrelevant" | "inaccurate" | "too_long" | "too_short" | "other";
|
|
72
|
+
/** A single structured feedback submission from a user. */
|
|
73
|
+
export interface FeedbackEntry {
|
|
74
|
+
/** Unique identifier for this feedback entry. */
|
|
75
|
+
readonly feedback_id: string;
|
|
76
|
+
/** Satisfaction rating from 1 (very poor) to 5 (excellent). */
|
|
77
|
+
readonly rating: number;
|
|
78
|
+
/** Structured category label for quick classification. */
|
|
79
|
+
readonly category: FeedbackCategory;
|
|
80
|
+
/** The agent that produced the response being rated. */
|
|
81
|
+
readonly agent_id: string;
|
|
82
|
+
/** Optional session identifier for grouping feedback. */
|
|
83
|
+
readonly session_id: string;
|
|
84
|
+
/** Optional identifier for the specific interaction being rated. */
|
|
85
|
+
readonly interaction_id: string;
|
|
86
|
+
/** Optional free-form user comment. */
|
|
87
|
+
readonly free_text: string;
|
|
88
|
+
/** ISO-8601 UTC datetime when feedback was submitted. */
|
|
89
|
+
readonly submitted_at: string;
|
|
90
|
+
/** Whether this is positive feedback (rating >= 4 or category = helpful). */
|
|
91
|
+
readonly is_positive: boolean;
|
|
92
|
+
/** Whether this is negative feedback (rating <= 2 or category = harmful/unhelpful). */
|
|
93
|
+
readonly is_negative: boolean;
|
|
94
|
+
/** Arbitrary additional key-value metadata. */
|
|
95
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
96
|
+
}
|
|
97
|
+
/** Request payload for submitting feedback. */
|
|
98
|
+
export interface FeedbackSubmitRequest {
|
|
99
|
+
/** Satisfaction rating from 1 to 5. */
|
|
100
|
+
readonly rating: number;
|
|
101
|
+
/** Structured category label. */
|
|
102
|
+
readonly category: FeedbackCategory;
|
|
103
|
+
/** The agent being rated. */
|
|
104
|
+
readonly agent_id: string;
|
|
105
|
+
/** Optional session identifier. */
|
|
106
|
+
readonly session_id?: string;
|
|
107
|
+
/** Optional interaction identifier. */
|
|
108
|
+
readonly interaction_id?: string;
|
|
109
|
+
/** Optional free-form comment. */
|
|
110
|
+
readonly free_text?: string;
|
|
111
|
+
/** Optional additional metadata. */
|
|
112
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
113
|
+
}
|
|
114
|
+
/** Aggregated feedback statistics for an agent. */
|
|
115
|
+
export interface FeedbackSummary {
|
|
116
|
+
/** The agent this summary covers. */
|
|
117
|
+
readonly agent_id: string;
|
|
118
|
+
/** Total number of feedback entries processed. */
|
|
119
|
+
readonly total_feedback: number;
|
|
120
|
+
/** Mean rating across all entries (1–5). */
|
|
121
|
+
readonly average_rating: number;
|
|
122
|
+
/** Normalised satisfaction score in [0, 1]. */
|
|
123
|
+
readonly satisfaction_score: number;
|
|
124
|
+
/** Count of feedback entries per category. */
|
|
125
|
+
readonly category_distribution: Readonly<Record<string, number>>;
|
|
126
|
+
/** Number of positive feedback entries. */
|
|
127
|
+
readonly positive_count: number;
|
|
128
|
+
/** Number of negative feedback entries. */
|
|
129
|
+
readonly negative_count: number;
|
|
130
|
+
/** Number of neutral feedback entries (rating = 3). */
|
|
131
|
+
readonly neutral_count: number;
|
|
132
|
+
/** Most frequent words from free-text comments. */
|
|
133
|
+
readonly top_free_text_keywords: readonly string[];
|
|
134
|
+
/** ISO-8601 UTC datetime when this summary was computed. */
|
|
135
|
+
readonly computed_at: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Canonical device categories.
|
|
139
|
+
* Maps to DeviceType enum in Python.
|
|
140
|
+
*/
|
|
141
|
+
export type DeviceType = "desktop" | "mobile" | "tablet" | "voice" | "unknown";
|
|
142
|
+
/**
|
|
143
|
+
* Inferred network quality tiers.
|
|
144
|
+
* Maps to NetworkQuality enum in Python.
|
|
145
|
+
*/
|
|
146
|
+
export type NetworkQuality = "high" | "medium" | "low" | "unknown";
|
|
147
|
+
/** Feature flags inferred from User-Agent and hints headers. */
|
|
148
|
+
export interface BrowserCapabilities {
|
|
149
|
+
readonly javascript_enabled: boolean;
|
|
150
|
+
readonly webgl_supported: boolean;
|
|
151
|
+
readonly touch_supported: boolean;
|
|
152
|
+
readonly screen_reader_likely: boolean;
|
|
153
|
+
readonly reduced_motion_preferred: boolean;
|
|
154
|
+
}
|
|
155
|
+
/** Full result of a context detection call. */
|
|
156
|
+
export interface DetectedContext {
|
|
157
|
+
readonly device_type: DeviceType;
|
|
158
|
+
readonly network_quality: NetworkQuality;
|
|
159
|
+
readonly browser_capabilities: BrowserCapabilities;
|
|
160
|
+
readonly user_agent: string;
|
|
161
|
+
readonly raw_headers: Readonly<Record<string, string>>;
|
|
162
|
+
}
|
|
163
|
+
/** Intent parsed from a user utterance. */
|
|
164
|
+
export interface UserIntent {
|
|
165
|
+
/** The raw user utterance. */
|
|
166
|
+
readonly utterance: string;
|
|
167
|
+
/** Primary intent label (e.g. "question", "command", "clarification"). */
|
|
168
|
+
readonly intent: string;
|
|
169
|
+
/** Confidence score for this intent classification in [0, 1]. */
|
|
170
|
+
readonly confidence: number;
|
|
171
|
+
/** Extracted named entities. */
|
|
172
|
+
readonly entities: Readonly<Record<string, string>>;
|
|
173
|
+
/** ISO-8601 UTC timestamp when this intent was parsed. */
|
|
174
|
+
readonly parsed_at: string;
|
|
175
|
+
}
|
|
176
|
+
/** Ranked response candidate with score. */
|
|
177
|
+
export interface ResponseCandidate {
|
|
178
|
+
/** Unique identifier for this candidate. */
|
|
179
|
+
readonly candidate_id: string;
|
|
180
|
+
/** The response text. */
|
|
181
|
+
readonly text: string;
|
|
182
|
+
/** Composite ranking score in [0, 1] (higher = preferred). */
|
|
183
|
+
readonly score: number;
|
|
184
|
+
/** Context match contribution to the score. */
|
|
185
|
+
readonly context_match_score: number;
|
|
186
|
+
/** Relevance contribution to the score. */
|
|
187
|
+
readonly relevance_score: number;
|
|
188
|
+
}
|
|
189
|
+
/** Current state of a dialogue session. */
|
|
190
|
+
export interface DialogueState {
|
|
191
|
+
/** Unique session identifier. */
|
|
192
|
+
readonly session_id: string;
|
|
193
|
+
/** Current turn number (1-indexed). */
|
|
194
|
+
readonly turn_number: number;
|
|
195
|
+
/** Detected context for this session. */
|
|
196
|
+
readonly detected_context: DetectedContext;
|
|
197
|
+
/** Current confidence level for the session. */
|
|
198
|
+
readonly confidence_level: ConfidenceLevel;
|
|
199
|
+
/** ISO-8601 UTC timestamp of the last activity. */
|
|
200
|
+
readonly last_activity_at: string;
|
|
201
|
+
/** Whether a human handoff has been triggered. */
|
|
202
|
+
readonly handoff_triggered: boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* WCAG 2.1 conformance level.
|
|
206
|
+
* Maps to WCAGLevel enum in Python.
|
|
207
|
+
*/
|
|
208
|
+
export type WCAGLevel = "A" | "AA" | "AAA";
|
|
209
|
+
/** A single WCAG 2.1 violation found in inspected content. */
|
|
210
|
+
export interface WCAGViolation {
|
|
211
|
+
/** WCAG success criterion number (e.g. "1.1.1"). */
|
|
212
|
+
readonly criterion: string;
|
|
213
|
+
/** Conformance level of the criterion. */
|
|
214
|
+
readonly level: WCAGLevel;
|
|
215
|
+
/** Human-readable description of the violation. */
|
|
216
|
+
readonly description: string;
|
|
217
|
+
/** Short snippet of the problematic markup or text. */
|
|
218
|
+
readonly element_snippet: string;
|
|
219
|
+
/** Recommended remediation for the violation. */
|
|
220
|
+
readonly suggestion: string;
|
|
221
|
+
}
|
|
222
|
+
/** Result of an accessibility check. */
|
|
223
|
+
export interface AccessibilityCheckResult {
|
|
224
|
+
/** Whether the content passed all WCAG checks. */
|
|
225
|
+
readonly passed: boolean;
|
|
226
|
+
/** List of WCAG violations found. */
|
|
227
|
+
readonly violations: readonly WCAGViolation[];
|
|
228
|
+
/** Per-criterion violation counts. */
|
|
229
|
+
readonly violation_counts: Readonly<Record<string, number>>;
|
|
230
|
+
}
|
|
231
|
+
/** Configuration for an accessibility check request. */
|
|
232
|
+
export interface AccessibilityConfig {
|
|
233
|
+
/** HTML markup or text content to check. */
|
|
234
|
+
readonly html: string;
|
|
235
|
+
/** Whether to check color contrast. */
|
|
236
|
+
readonly check_color_contrast?: boolean;
|
|
237
|
+
/** Whether to check text alternatives for images. */
|
|
238
|
+
readonly check_text_alternatives?: boolean;
|
|
239
|
+
/** Whether to check heading hierarchy. */
|
|
240
|
+
readonly check_heading_hierarchy?: boolean;
|
|
241
|
+
/** Whether to check link text descriptiveness. */
|
|
242
|
+
readonly check_link_text?: boolean;
|
|
243
|
+
}
|
|
244
|
+
/** Standard error payload returned by the agent-sense API. */
|
|
245
|
+
export interface ApiError {
|
|
246
|
+
readonly error: string;
|
|
247
|
+
readonly detail: string;
|
|
248
|
+
}
|
|
249
|
+
/** Result type for all client operations. */
|
|
250
|
+
export type ApiResult<T> = {
|
|
251
|
+
readonly ok: true;
|
|
252
|
+
readonly data: T;
|
|
253
|
+
} | {
|
|
254
|
+
readonly ok: false;
|
|
255
|
+
readonly error: ApiError;
|
|
256
|
+
readonly status: number;
|
|
257
|
+
};
|
|
258
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,KAAK,GACL,QAAQ,GACR,MAAM,GACN,WAAW,CAAC;AAEhB,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,C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,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACvC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-sense transparency layer.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python dataclasses and Pydantic models defined in:
|
|
5
|
+
* agent_sense.indicators.confidence (ConfidenceLevel, ConfidenceIndicator)
|
|
6
|
+
* agent_sense.indicators.disclosure (DisclosureLevel, AIDisclosureCard)
|
|
7
|
+
* agent_sense.feedback.collector (FeedbackCategory, FeedbackEntry, FeedbackSummary)
|
|
8
|
+
* agent_sense.context.detector (DeviceType, NetworkQuality, BrowserCapabilities, DetectedContext)
|
|
9
|
+
* agent_sense.accessibility.wcag (WCAGLevel, WCAGViolation)
|
|
10
|
+
* agent_sense.disclosure.transparency (SessionStats)
|
|
11
|
+
*
|
|
12
|
+
* All interfaces use readonly fields to match Python frozen dataclasses.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aumos/agent-sense",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for the AumOS agent-sense transparency layer — dialogue context, intent parsing, response ranking, feedback collection, and accessibility",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.3.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"aumos",
|
|
24
|
+
"agent-sense",
|
|
25
|
+
"transparency",
|
|
26
|
+
"accessibility",
|
|
27
|
+
"confidence",
|
|
28
|
+
"intent",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/aumos-ai/agent-sense"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-sense transparency API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentSenseClient } from "@aumos/agent-sense";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentSenseClient({ baseUrl: "http://localhost:8091" });
|
|
12
|
+
*
|
|
13
|
+
* const intent = await client.parseIntent({
|
|
14
|
+
* utterance: "Show me my account balance",
|
|
15
|
+
* session_id: "sess-001",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (intent.ok) {
|
|
19
|
+
* console.log("Parsed intent:", intent.data.intent);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type {
|
|
25
|
+
AccessibilityCheckResult,
|
|
26
|
+
AccessibilityConfig,
|
|
27
|
+
ApiError,
|
|
28
|
+
ApiResult,
|
|
29
|
+
DetectedContext,
|
|
30
|
+
DialogueState,
|
|
31
|
+
FeedbackEntry,
|
|
32
|
+
FeedbackSubmitRequest,
|
|
33
|
+
FeedbackSummary,
|
|
34
|
+
ResponseCandidate,
|
|
35
|
+
TransparencyIndicator,
|
|
36
|
+
UserIntent,
|
|
37
|
+
} from "./types.js";
|
|
38
|
+
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Client configuration
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
/** Configuration options for the AgentSenseClient. */
|
|
44
|
+
export interface AgentSenseClientConfig {
|
|
45
|
+
/** Base URL of the agent-sense server (e.g. "http://localhost:8091"). */
|
|
46
|
+
readonly baseUrl: string;
|
|
47
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
48
|
+
readonly timeoutMs?: number;
|
|
49
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
50
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Internal helpers
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
async function fetchJson<T>(
|
|
58
|
+
url: string,
|
|
59
|
+
init: RequestInit,
|
|
60
|
+
timeoutMs: number,
|
|
61
|
+
): Promise<ApiResult<T>> {
|
|
62
|
+
const controller = new AbortController();
|
|
63
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
|
|
69
|
+
const body = await response.json() as unknown;
|
|
70
|
+
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
const errorBody = body as Partial<ApiError>;
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
error: {
|
|
76
|
+
error: errorBody.error ?? "Unknown error",
|
|
77
|
+
detail: errorBody.detail ?? "",
|
|
78
|
+
},
|
|
79
|
+
status: response.status,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return { ok: true, data: body as T };
|
|
84
|
+
} catch (err: unknown) {
|
|
85
|
+
clearTimeout(timeoutId);
|
|
86
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
87
|
+
return {
|
|
88
|
+
ok: false,
|
|
89
|
+
error: { error: "Network error", detail: message },
|
|
90
|
+
status: 0,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function buildHeaders(
|
|
96
|
+
extraHeaders: Readonly<Record<string, string>> | undefined,
|
|
97
|
+
): Record<string, string> {
|
|
98
|
+
return {
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
Accept: "application/json",
|
|
101
|
+
...extraHeaders,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
// Client interface
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
/** Typed HTTP client for the agent-sense server. */
|
|
110
|
+
export interface AgentSenseClient {
|
|
111
|
+
/**
|
|
112
|
+
* Parse the intent from a user utterance.
|
|
113
|
+
*
|
|
114
|
+
* @param options - Utterance and optional session context.
|
|
115
|
+
* @returns A UserIntent record with intent label, confidence, and entities.
|
|
116
|
+
*/
|
|
117
|
+
parseIntent(options: {
|
|
118
|
+
utterance: string;
|
|
119
|
+
session_id?: string;
|
|
120
|
+
context?: Readonly<Record<string, unknown>>;
|
|
121
|
+
}): Promise<ApiResult<UserIntent>>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Rank a list of response candidates for the given context.
|
|
125
|
+
*
|
|
126
|
+
* @param options - Candidates, user text, and optional history.
|
|
127
|
+
* @returns The candidates re-ordered by composite score.
|
|
128
|
+
*/
|
|
129
|
+
rankResponses(options: {
|
|
130
|
+
candidates: readonly { candidate_id: string; text: string; relevance_score: number }[];
|
|
131
|
+
user_text: string;
|
|
132
|
+
history?: readonly string[];
|
|
133
|
+
recent_shown?: readonly string[];
|
|
134
|
+
}): Promise<ApiResult<readonly ResponseCandidate[]>>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Submit structured feedback for an agent interaction.
|
|
138
|
+
*
|
|
139
|
+
* @param request - Feedback submission payload.
|
|
140
|
+
* @returns The stored FeedbackEntry record.
|
|
141
|
+
*/
|
|
142
|
+
collectFeedback(
|
|
143
|
+
request: FeedbackSubmitRequest,
|
|
144
|
+
): Promise<ApiResult<FeedbackEntry>>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Retrieve the current dialogue state for a session.
|
|
148
|
+
*
|
|
149
|
+
* @param sessionId - The session identifier.
|
|
150
|
+
* @returns The DialogueState record for this session.
|
|
151
|
+
*/
|
|
152
|
+
getDialogueState(sessionId: string): Promise<ApiResult<DialogueState>>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Check HTML content for WCAG 2.1 accessibility violations.
|
|
156
|
+
*
|
|
157
|
+
* @param config - Accessibility check configuration including HTML markup.
|
|
158
|
+
* @returns The check result with any violations found.
|
|
159
|
+
*/
|
|
160
|
+
checkAccessibility(
|
|
161
|
+
config: AccessibilityConfig,
|
|
162
|
+
): Promise<ApiResult<AccessibilityCheckResult>>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Get the transparency indicator (confidence + disclosure) for an agent.
|
|
166
|
+
*
|
|
167
|
+
* @param options - Agent ID and optional session context.
|
|
168
|
+
* @returns A TransparencyIndicator combining confidence and disclosure.
|
|
169
|
+
*/
|
|
170
|
+
getTransparencyIndicator(options: {
|
|
171
|
+
agent_id: string;
|
|
172
|
+
session_id?: string;
|
|
173
|
+
}): Promise<ApiResult<TransparencyIndicator>>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Detect the client context from a User-Agent string and HTTP headers.
|
|
177
|
+
*
|
|
178
|
+
* @param options - User-Agent string and optional HTTP hint headers.
|
|
179
|
+
* @returns A DetectedContext with device type, network quality, and capabilities.
|
|
180
|
+
*/
|
|
181
|
+
detectContext(options: {
|
|
182
|
+
user_agent: string;
|
|
183
|
+
headers?: Readonly<Record<string, string>>;
|
|
184
|
+
}): Promise<ApiResult<DetectedContext>>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get aggregated feedback summary for an agent.
|
|
188
|
+
*
|
|
189
|
+
* @param agentId - The agent identifier.
|
|
190
|
+
* @returns A FeedbackSummary with satisfaction score and category breakdown.
|
|
191
|
+
*/
|
|
192
|
+
getFeedbackSummary(agentId: string): Promise<ApiResult<FeedbackSummary>>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
// Client factory
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Create a typed HTTP client for the agent-sense server.
|
|
201
|
+
*
|
|
202
|
+
* @param config - Client configuration including base URL.
|
|
203
|
+
* @returns An AgentSenseClient instance.
|
|
204
|
+
*/
|
|
205
|
+
export function createAgentSenseClient(
|
|
206
|
+
config: AgentSenseClientConfig,
|
|
207
|
+
): AgentSenseClient {
|
|
208
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
209
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
async parseIntent(options: {
|
|
213
|
+
utterance: string;
|
|
214
|
+
session_id?: string;
|
|
215
|
+
context?: Readonly<Record<string, unknown>>;
|
|
216
|
+
}): Promise<ApiResult<UserIntent>> {
|
|
217
|
+
return fetchJson<UserIntent>(
|
|
218
|
+
`${baseUrl}/sense/intent`,
|
|
219
|
+
{
|
|
220
|
+
method: "POST",
|
|
221
|
+
headers: baseHeaders,
|
|
222
|
+
body: JSON.stringify(options),
|
|
223
|
+
},
|
|
224
|
+
timeoutMs,
|
|
225
|
+
);
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
async rankResponses(options: {
|
|
229
|
+
candidates: readonly { candidate_id: string; text: string; relevance_score: number }[];
|
|
230
|
+
user_text: string;
|
|
231
|
+
history?: readonly string[];
|
|
232
|
+
recent_shown?: readonly string[];
|
|
233
|
+
}): Promise<ApiResult<readonly ResponseCandidate[]>> {
|
|
234
|
+
return fetchJson<readonly ResponseCandidate[]>(
|
|
235
|
+
`${baseUrl}/sense/rank`,
|
|
236
|
+
{
|
|
237
|
+
method: "POST",
|
|
238
|
+
headers: baseHeaders,
|
|
239
|
+
body: JSON.stringify(options),
|
|
240
|
+
},
|
|
241
|
+
timeoutMs,
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
async collectFeedback(
|
|
246
|
+
request: FeedbackSubmitRequest,
|
|
247
|
+
): Promise<ApiResult<FeedbackEntry>> {
|
|
248
|
+
return fetchJson<FeedbackEntry>(
|
|
249
|
+
`${baseUrl}/sense/feedback`,
|
|
250
|
+
{
|
|
251
|
+
method: "POST",
|
|
252
|
+
headers: baseHeaders,
|
|
253
|
+
body: JSON.stringify(request),
|
|
254
|
+
},
|
|
255
|
+
timeoutMs,
|
|
256
|
+
);
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
async getDialogueState(sessionId: string): Promise<ApiResult<DialogueState>> {
|
|
260
|
+
return fetchJson<DialogueState>(
|
|
261
|
+
`${baseUrl}/sense/sessions/${encodeURIComponent(sessionId)}/state`,
|
|
262
|
+
{ method: "GET", headers: baseHeaders },
|
|
263
|
+
timeoutMs,
|
|
264
|
+
);
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
async checkAccessibility(
|
|
268
|
+
config: AccessibilityConfig,
|
|
269
|
+
): Promise<ApiResult<AccessibilityCheckResult>> {
|
|
270
|
+
return fetchJson<AccessibilityCheckResult>(
|
|
271
|
+
`${baseUrl}/sense/accessibility/check`,
|
|
272
|
+
{
|
|
273
|
+
method: "POST",
|
|
274
|
+
headers: baseHeaders,
|
|
275
|
+
body: JSON.stringify(config),
|
|
276
|
+
},
|
|
277
|
+
timeoutMs,
|
|
278
|
+
);
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
async getTransparencyIndicator(options: {
|
|
282
|
+
agent_id: string;
|
|
283
|
+
session_id?: string;
|
|
284
|
+
}): Promise<ApiResult<TransparencyIndicator>> {
|
|
285
|
+
const params = new URLSearchParams();
|
|
286
|
+
params.set("agent_id", options.agent_id);
|
|
287
|
+
if (options.session_id !== undefined) {
|
|
288
|
+
params.set("session_id", options.session_id);
|
|
289
|
+
}
|
|
290
|
+
return fetchJson<TransparencyIndicator>(
|
|
291
|
+
`${baseUrl}/sense/transparency?${params.toString()}`,
|
|
292
|
+
{ method: "GET", headers: baseHeaders },
|
|
293
|
+
timeoutMs,
|
|
294
|
+
);
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
async detectContext(options: {
|
|
298
|
+
user_agent: string;
|
|
299
|
+
headers?: Readonly<Record<string, string>>;
|
|
300
|
+
}): Promise<ApiResult<DetectedContext>> {
|
|
301
|
+
return fetchJson<DetectedContext>(
|
|
302
|
+
`${baseUrl}/sense/context/detect`,
|
|
303
|
+
{
|
|
304
|
+
method: "POST",
|
|
305
|
+
headers: baseHeaders,
|
|
306
|
+
body: JSON.stringify(options),
|
|
307
|
+
},
|
|
308
|
+
timeoutMs,
|
|
309
|
+
);
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
async getFeedbackSummary(agentId: string): Promise<ApiResult<FeedbackSummary>> {
|
|
313
|
+
return fetchJson<FeedbackSummary>(
|
|
314
|
+
`${baseUrl}/sense/feedback/${encodeURIComponent(agentId)}/summary`,
|
|
315
|
+
{ method: "GET", headers: baseHeaders },
|
|
316
|
+
timeoutMs,
|
|
317
|
+
);
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-sense
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-sense transparency layer.
|
|
5
|
+
* Provides HTTP client, intent parsing, response ranking, feedback collection,
|
|
6
|
+
* accessibility checking, and confidence/disclosure type definitions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Client and configuration
|
|
10
|
+
export type { AgentSenseClient, AgentSenseClientConfig } from "./client.js";
|
|
11
|
+
export { createAgentSenseClient } from "./client.js";
|
|
12
|
+
|
|
13
|
+
// Core types
|
|
14
|
+
export type {
|
|
15
|
+
AccessibilityCheckResult,
|
|
16
|
+
AccessibilityConfig,
|
|
17
|
+
AIDisclosureCard,
|
|
18
|
+
ApiError,
|
|
19
|
+
ApiResult,
|
|
20
|
+
BrowserCapabilities,
|
|
21
|
+
ConfidenceIndicator,
|
|
22
|
+
ConfidenceLevel,
|
|
23
|
+
DetectedContext,
|
|
24
|
+
DeviceType,
|
|
25
|
+
DialogueState,
|
|
26
|
+
DisclosureLevel,
|
|
27
|
+
FeedbackCategory,
|
|
28
|
+
FeedbackEntry,
|
|
29
|
+
FeedbackSubmitRequest,
|
|
30
|
+
FeedbackSummary,
|
|
31
|
+
NetworkQuality,
|
|
32
|
+
ResponseCandidate,
|
|
33
|
+
TransparencyIndicator,
|
|
34
|
+
UserIntent,
|
|
35
|
+
WCAGLevel,
|
|
36
|
+
WCAGViolation,
|
|
37
|
+
} from "./types.js";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-sense transparency layer.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python dataclasses and Pydantic models defined in:
|
|
5
|
+
* agent_sense.indicators.confidence (ConfidenceLevel, ConfidenceIndicator)
|
|
6
|
+
* agent_sense.indicators.disclosure (DisclosureLevel, AIDisclosureCard)
|
|
7
|
+
* agent_sense.feedback.collector (FeedbackCategory, FeedbackEntry, FeedbackSummary)
|
|
8
|
+
* agent_sense.context.detector (DeviceType, NetworkQuality, BrowserCapabilities, DetectedContext)
|
|
9
|
+
* agent_sense.accessibility.wcag (WCAGLevel, WCAGViolation)
|
|
10
|
+
* agent_sense.disclosure.transparency (SessionStats)
|
|
11
|
+
*
|
|
12
|
+
* All interfaces use readonly fields to match Python frozen dataclasses.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Confidence types
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Five-tier categorical confidence classification.
|
|
21
|
+
* Maps to ConfidenceLevel enum in Python.
|
|
22
|
+
* Score bands: very_low [0,0.2), low [0.2,0.4), medium [0.4,0.6),
|
|
23
|
+
* high [0.6,0.8), very_high [0.8,1.0].
|
|
24
|
+
*/
|
|
25
|
+
export type ConfidenceLevel =
|
|
26
|
+
| "very_low"
|
|
27
|
+
| "low"
|
|
28
|
+
| "medium"
|
|
29
|
+
| "high"
|
|
30
|
+
| "very_high";
|
|
31
|
+
|
|
32
|
+
/** Structured confidence measurement for an AI agent response. */
|
|
33
|
+
export interface ConfidenceIndicator {
|
|
34
|
+
/** Raw numeric confidence in [0.0, 1.0]. */
|
|
35
|
+
readonly score: number;
|
|
36
|
+
/** Categorical tier derived from score. */
|
|
37
|
+
readonly level: ConfidenceLevel;
|
|
38
|
+
/** Human-readable explanation of the confidence assessment. */
|
|
39
|
+
readonly reasoning: string;
|
|
40
|
+
/** Map of contributing factor names to their individual scores [0, 1]. */
|
|
41
|
+
readonly factors: Readonly<Record<string, number>>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Disclosure types
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Controls the verbosity of disclosure card rendering.
|
|
50
|
+
* Maps to DisclosureLevel enum in Python.
|
|
51
|
+
*/
|
|
52
|
+
export type DisclosureLevel = "minimal" | "standard" | "detailed" | "full";
|
|
53
|
+
|
|
54
|
+
/** Immutable disclosure card for an AI agent deployment. */
|
|
55
|
+
export interface AIDisclosureCard {
|
|
56
|
+
/** Human-readable name of the agent. */
|
|
57
|
+
readonly agent_name: string;
|
|
58
|
+
/** Semantic version or build identifier. */
|
|
59
|
+
readonly agent_version: string;
|
|
60
|
+
/** Organisation that produced the underlying model. */
|
|
61
|
+
readonly model_provider: string;
|
|
62
|
+
/** Identifier of the specific model being used. */
|
|
63
|
+
readonly model_name: string;
|
|
64
|
+
/** Ordered list of things this agent can do well. */
|
|
65
|
+
readonly capabilities: readonly string[];
|
|
66
|
+
/** Ordered list of known constraints or failure modes. */
|
|
67
|
+
readonly limitations: readonly string[];
|
|
68
|
+
/** Plain-language description of how conversation data is handled. */
|
|
69
|
+
readonly data_handling: string;
|
|
70
|
+
/** ISO-8601 UTC datetime at which this card was last revised. */
|
|
71
|
+
readonly last_updated: string;
|
|
72
|
+
/** Verbosity level used when rendering this card. */
|
|
73
|
+
readonly disclosure_level: DisclosureLevel;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Transparency indicator (combined type requested by spec)
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
/** Full transparency indicator combining confidence and disclosure. */
|
|
81
|
+
export interface TransparencyIndicator {
|
|
82
|
+
/** The confidence measurement for a response. */
|
|
83
|
+
readonly confidence: ConfidenceIndicator;
|
|
84
|
+
/** The AI disclosure card for this deployment. */
|
|
85
|
+
readonly disclosure: AIDisclosureCard;
|
|
86
|
+
/** ISO-8601 UTC timestamp when this indicator was generated. */
|
|
87
|
+
readonly generated_at: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Feedback types
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Category labels for user feedback.
|
|
96
|
+
* Maps to FeedbackCategory enum in Python.
|
|
97
|
+
*/
|
|
98
|
+
export type FeedbackCategory =
|
|
99
|
+
| "helpful"
|
|
100
|
+
| "unhelpful"
|
|
101
|
+
| "harmful"
|
|
102
|
+
| "irrelevant"
|
|
103
|
+
| "inaccurate"
|
|
104
|
+
| "too_long"
|
|
105
|
+
| "too_short"
|
|
106
|
+
| "other";
|
|
107
|
+
|
|
108
|
+
/** A single structured feedback submission from a user. */
|
|
109
|
+
export interface FeedbackEntry {
|
|
110
|
+
/** Unique identifier for this feedback entry. */
|
|
111
|
+
readonly feedback_id: string;
|
|
112
|
+
/** Satisfaction rating from 1 (very poor) to 5 (excellent). */
|
|
113
|
+
readonly rating: number;
|
|
114
|
+
/** Structured category label for quick classification. */
|
|
115
|
+
readonly category: FeedbackCategory;
|
|
116
|
+
/** The agent that produced the response being rated. */
|
|
117
|
+
readonly agent_id: string;
|
|
118
|
+
/** Optional session identifier for grouping feedback. */
|
|
119
|
+
readonly session_id: string;
|
|
120
|
+
/** Optional identifier for the specific interaction being rated. */
|
|
121
|
+
readonly interaction_id: string;
|
|
122
|
+
/** Optional free-form user comment. */
|
|
123
|
+
readonly free_text: string;
|
|
124
|
+
/** ISO-8601 UTC datetime when feedback was submitted. */
|
|
125
|
+
readonly submitted_at: string;
|
|
126
|
+
/** Whether this is positive feedback (rating >= 4 or category = helpful). */
|
|
127
|
+
readonly is_positive: boolean;
|
|
128
|
+
/** Whether this is negative feedback (rating <= 2 or category = harmful/unhelpful). */
|
|
129
|
+
readonly is_negative: boolean;
|
|
130
|
+
/** Arbitrary additional key-value metadata. */
|
|
131
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Request payload for submitting feedback. */
|
|
135
|
+
export interface FeedbackSubmitRequest {
|
|
136
|
+
/** Satisfaction rating from 1 to 5. */
|
|
137
|
+
readonly rating: number;
|
|
138
|
+
/** Structured category label. */
|
|
139
|
+
readonly category: FeedbackCategory;
|
|
140
|
+
/** The agent being rated. */
|
|
141
|
+
readonly agent_id: string;
|
|
142
|
+
/** Optional session identifier. */
|
|
143
|
+
readonly session_id?: string;
|
|
144
|
+
/** Optional interaction identifier. */
|
|
145
|
+
readonly interaction_id?: string;
|
|
146
|
+
/** Optional free-form comment. */
|
|
147
|
+
readonly free_text?: string;
|
|
148
|
+
/** Optional additional metadata. */
|
|
149
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Aggregated feedback statistics for an agent. */
|
|
153
|
+
export interface FeedbackSummary {
|
|
154
|
+
/** The agent this summary covers. */
|
|
155
|
+
readonly agent_id: string;
|
|
156
|
+
/** Total number of feedback entries processed. */
|
|
157
|
+
readonly total_feedback: number;
|
|
158
|
+
/** Mean rating across all entries (1–5). */
|
|
159
|
+
readonly average_rating: number;
|
|
160
|
+
/** Normalised satisfaction score in [0, 1]. */
|
|
161
|
+
readonly satisfaction_score: number;
|
|
162
|
+
/** Count of feedback entries per category. */
|
|
163
|
+
readonly category_distribution: Readonly<Record<string, number>>;
|
|
164
|
+
/** Number of positive feedback entries. */
|
|
165
|
+
readonly positive_count: number;
|
|
166
|
+
/** Number of negative feedback entries. */
|
|
167
|
+
readonly negative_count: number;
|
|
168
|
+
/** Number of neutral feedback entries (rating = 3). */
|
|
169
|
+
readonly neutral_count: number;
|
|
170
|
+
/** Most frequent words from free-text comments. */
|
|
171
|
+
readonly top_free_text_keywords: readonly string[];
|
|
172
|
+
/** ISO-8601 UTC datetime when this summary was computed. */
|
|
173
|
+
readonly computed_at: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
// Dialogue / context types
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Canonical device categories.
|
|
182
|
+
* Maps to DeviceType enum in Python.
|
|
183
|
+
*/
|
|
184
|
+
export type DeviceType = "desktop" | "mobile" | "tablet" | "voice" | "unknown";
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Inferred network quality tiers.
|
|
188
|
+
* Maps to NetworkQuality enum in Python.
|
|
189
|
+
*/
|
|
190
|
+
export type NetworkQuality = "high" | "medium" | "low" | "unknown";
|
|
191
|
+
|
|
192
|
+
/** Feature flags inferred from User-Agent and hints headers. */
|
|
193
|
+
export interface BrowserCapabilities {
|
|
194
|
+
readonly javascript_enabled: boolean;
|
|
195
|
+
readonly webgl_supported: boolean;
|
|
196
|
+
readonly touch_supported: boolean;
|
|
197
|
+
readonly screen_reader_likely: boolean;
|
|
198
|
+
readonly reduced_motion_preferred: boolean;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Full result of a context detection call. */
|
|
202
|
+
export interface DetectedContext {
|
|
203
|
+
readonly device_type: DeviceType;
|
|
204
|
+
readonly network_quality: NetworkQuality;
|
|
205
|
+
readonly browser_capabilities: BrowserCapabilities;
|
|
206
|
+
readonly user_agent: string;
|
|
207
|
+
readonly raw_headers: Readonly<Record<string, string>>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Intent parsed from a user utterance. */
|
|
211
|
+
export interface UserIntent {
|
|
212
|
+
/** The raw user utterance. */
|
|
213
|
+
readonly utterance: string;
|
|
214
|
+
/** Primary intent label (e.g. "question", "command", "clarification"). */
|
|
215
|
+
readonly intent: string;
|
|
216
|
+
/** Confidence score for this intent classification in [0, 1]. */
|
|
217
|
+
readonly confidence: number;
|
|
218
|
+
/** Extracted named entities. */
|
|
219
|
+
readonly entities: Readonly<Record<string, string>>;
|
|
220
|
+
/** ISO-8601 UTC timestamp when this intent was parsed. */
|
|
221
|
+
readonly parsed_at: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Ranked response candidate with score. */
|
|
225
|
+
export interface ResponseCandidate {
|
|
226
|
+
/** Unique identifier for this candidate. */
|
|
227
|
+
readonly candidate_id: string;
|
|
228
|
+
/** The response text. */
|
|
229
|
+
readonly text: string;
|
|
230
|
+
/** Composite ranking score in [0, 1] (higher = preferred). */
|
|
231
|
+
readonly score: number;
|
|
232
|
+
/** Context match contribution to the score. */
|
|
233
|
+
readonly context_match_score: number;
|
|
234
|
+
/** Relevance contribution to the score. */
|
|
235
|
+
readonly relevance_score: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Current state of a dialogue session. */
|
|
239
|
+
export interface DialogueState {
|
|
240
|
+
/** Unique session identifier. */
|
|
241
|
+
readonly session_id: string;
|
|
242
|
+
/** Current turn number (1-indexed). */
|
|
243
|
+
readonly turn_number: number;
|
|
244
|
+
/** Detected context for this session. */
|
|
245
|
+
readonly detected_context: DetectedContext;
|
|
246
|
+
/** Current confidence level for the session. */
|
|
247
|
+
readonly confidence_level: ConfidenceLevel;
|
|
248
|
+
/** ISO-8601 UTC timestamp of the last activity. */
|
|
249
|
+
readonly last_activity_at: string;
|
|
250
|
+
/** Whether a human handoff has been triggered. */
|
|
251
|
+
readonly handoff_triggered: boolean;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ---------------------------------------------------------------------------
|
|
255
|
+
// Accessibility types
|
|
256
|
+
// ---------------------------------------------------------------------------
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* WCAG 2.1 conformance level.
|
|
260
|
+
* Maps to WCAGLevel enum in Python.
|
|
261
|
+
*/
|
|
262
|
+
export type WCAGLevel = "A" | "AA" | "AAA";
|
|
263
|
+
|
|
264
|
+
/** A single WCAG 2.1 violation found in inspected content. */
|
|
265
|
+
export interface WCAGViolation {
|
|
266
|
+
/** WCAG success criterion number (e.g. "1.1.1"). */
|
|
267
|
+
readonly criterion: string;
|
|
268
|
+
/** Conformance level of the criterion. */
|
|
269
|
+
readonly level: WCAGLevel;
|
|
270
|
+
/** Human-readable description of the violation. */
|
|
271
|
+
readonly description: string;
|
|
272
|
+
/** Short snippet of the problematic markup or text. */
|
|
273
|
+
readonly element_snippet: string;
|
|
274
|
+
/** Recommended remediation for the violation. */
|
|
275
|
+
readonly suggestion: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Result of an accessibility check. */
|
|
279
|
+
export interface AccessibilityCheckResult {
|
|
280
|
+
/** Whether the content passed all WCAG checks. */
|
|
281
|
+
readonly passed: boolean;
|
|
282
|
+
/** List of WCAG violations found. */
|
|
283
|
+
readonly violations: readonly WCAGViolation[];
|
|
284
|
+
/** Per-criterion violation counts. */
|
|
285
|
+
readonly violation_counts: Readonly<Record<string, number>>;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Configuration for an accessibility check request. */
|
|
289
|
+
export interface AccessibilityConfig {
|
|
290
|
+
/** HTML markup or text content to check. */
|
|
291
|
+
readonly html: string;
|
|
292
|
+
/** Whether to check color contrast. */
|
|
293
|
+
readonly check_color_contrast?: boolean;
|
|
294
|
+
/** Whether to check text alternatives for images. */
|
|
295
|
+
readonly check_text_alternatives?: boolean;
|
|
296
|
+
/** Whether to check heading hierarchy. */
|
|
297
|
+
readonly check_heading_hierarchy?: boolean;
|
|
298
|
+
/** Whether to check link text descriptiveness. */
|
|
299
|
+
readonly check_link_text?: boolean;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// ---------------------------------------------------------------------------
|
|
303
|
+
// API result wrapper (shared pattern)
|
|
304
|
+
// ---------------------------------------------------------------------------
|
|
305
|
+
|
|
306
|
+
/** Standard error payload returned by the agent-sense API. */
|
|
307
|
+
export interface ApiError {
|
|
308
|
+
readonly error: string;
|
|
309
|
+
readonly detail: string;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Result type for all client operations. */
|
|
313
|
+
export type ApiResult<T> =
|
|
314
|
+
| { readonly ok: true; readonly data: T }
|
|
315
|
+
| { readonly ok: false; readonly error: ApiError; readonly status: number };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"exactOptionalPropertyTypes": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"skipLibCheck": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*"],
|
|
24
|
+
"exclude": ["node_modules", "dist"]
|
|
25
|
+
}
|