@framers/agentos-ext-topicality 0.1.0 → 0.2.1

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/types.js CHANGED
@@ -1,215 +1,26 @@
1
1
  /**
2
- * @fileoverview Core type definitions for the Topicality guardrail extension pack.
2
+ * @file types.ts
3
+ * @description Core type definitions for the Topicality guardrail extension pack.
3
4
  *
4
- * This module defines every shared type, configuration interface, and preset
5
- * constant used across the topicality pipeline:
5
+ * Defines the configuration interface that controls which topics are allowed
6
+ * or blocked, similarity thresholds, and optional LLM fallback for ambiguous
7
+ * cases.
6
8
  *
7
- * - {@link TopicDescriptor} — declares a named topic with description + examples
8
- * - {@link TopicMatch} — a similarity score between text and a topic
9
- * - {@link DriftConfig} — tuning knobs for the EMA-based drift tracker
10
- * - {@link DEFAULT_DRIFT_CONFIG} — out-of-the-box sensible defaults
11
- * - {@link DriftResult} — output of a single drift-tracking update
12
- * - {@link TopicState} — per-session mutable state kept by the tracker
13
- * - {@link TopicalityPackOptions} — top-level options passed to the pack factory
14
- * - {@link TOPIC_PRESETS} — ready-made topic sets for common agent profiles
15
- *
16
- * All types are pure data shapes (no class logic) so they can be freely
17
- * serialised, logged, and passed across async boundaries.
18
- *
19
- * @module topicality/types
20
- */
21
- // ---------------------------------------------------------------------------
22
- // DEFAULT_DRIFT_CONFIG
23
- // ---------------------------------------------------------------------------
24
- /**
25
- * Sensible out-of-the-box defaults for {@link DriftConfig}.
26
- *
27
- * These values are designed for a production customer-support agent:
28
- * - `alpha = 0.3` — moderate memory; 3–4 messages to fully shift
29
- * - `driftThreshold = 0.3` — wide enough to allow tangential questions
30
- * - `driftStreakLimit = 3` — flag after 3 consecutive off-topic messages
31
- * - `sessionTimeoutMs = 3_600_000` — 1 hour idle timeout
32
- * - `maxSessions = 100` — suitable for low-to-medium concurrency agents
33
- *
34
- * Override individual fields via `{ ...DEFAULT_DRIFT_CONFIG, alpha: 0.5 }`.
9
+ * @module agentos/extensions/packs/topicality/types
35
10
  */
36
- export const DEFAULT_DRIFT_CONFIG = {
37
- alpha: 0.3,
38
- driftThreshold: 0.3,
39
- driftStreakLimit: 3,
40
- sessionTimeoutMs: 3_600_000,
41
- maxSessions: 100,
42
- };
43
11
  // ---------------------------------------------------------------------------
44
- // TOPIC_PRESETS
12
+ // Service identity constants
45
13
  // ---------------------------------------------------------------------------
46
14
  /**
47
- * Ready-made {@link TopicDescriptor} sets for the most common agent profiles.
15
+ * Stable string identifiers for services provided by the topicality pack.
48
16
  *
49
- * These presets are intentionally broad. They work as a starting point; add
50
- * domain-specific examples to improve precision for production deployments.
51
- *
52
- * @example
53
- * ```ts
54
- * const pack = createTopicalityPack({
55
- * allowedTopics: TOPIC_PRESETS.customerSupport,
56
- * forbiddenTopics: TOPIC_PRESETS.commonUnsafe,
57
- * });
58
- * ```
17
+ * Values follow the AgentOS convention: `agentos:<domain>:<service-name>`.
59
18
  */
60
- export const TOPIC_PRESETS = {
61
- /**
62
- * Five topics covering the typical scope of a SaaS customer-support agent.
63
- * Use as `allowedTopics` to restrict the agent to support conversations.
64
- */
65
- customerSupport: [
66
- {
67
- id: 'billing',
68
- name: 'Billing & Payments',
69
- description: 'Questions about invoices, charges, refunds, payment methods, and subscription management.',
70
- examples: [
71
- 'Why was I charged twice this month?',
72
- 'How do I update my credit card?',
73
- 'Can I get a refund for my last invoice?',
74
- 'When does my subscription renew?',
75
- 'How do I cancel my plan?',
76
- ],
77
- },
78
- {
79
- id: 'technical-support',
80
- name: 'Technical Support',
81
- description: 'Troubleshooting software bugs, login issues, performance problems, and integration errors.',
82
- examples: [
83
- "I can't log in to my account.",
84
- 'The app keeps crashing when I open it.',
85
- 'My API key is returning a 401 error.',
86
- 'How do I reset my password?',
87
- 'The dashboard is loading very slowly.',
88
- ],
89
- },
90
- {
91
- id: 'account-management',
92
- name: 'Account Management',
93
- description: 'Managing user profiles, team members, permissions, and organisation settings.',
94
- examples: [
95
- 'How do I add a new team member?',
96
- 'Can I change my account email address?',
97
- 'How do I remove a user from my organisation?',
98
- 'Where do I find my usage limits?',
99
- 'How do I enable two-factor authentication?',
100
- ],
101
- },
102
- {
103
- id: 'product-features',
104
- name: 'Product Features & Usage',
105
- description: 'How to use specific product features, best practices, and general how-to questions.',
106
- examples: [
107
- 'How do I export my data as CSV?',
108
- 'What integrations do you support?',
109
- 'Is there a mobile app available?',
110
- 'How does the search feature work?',
111
- 'Can I automate this with your API?',
112
- ],
113
- },
114
- {
115
- id: 'onboarding',
116
- name: 'Onboarding & Getting Started',
117
- description: 'Help for new users setting up their account, completing first-time setup, and understanding basics.',
118
- examples: [
119
- "I just signed up — where do I start?",
120
- 'How do I connect my data source?',
121
- 'Can you walk me through the initial setup?',
122
- 'What is the quickest way to get value from the product?',
123
- 'Is there a tutorial or quickstart guide?',
124
- ],
125
- },
126
- ],
127
- /**
128
- * Four topics covering the typical scope of a coding-assistant agent.
129
- * Use as `allowedTopics` to keep conversations focused on software development.
130
- */
131
- codingAssistant: [
132
- {
133
- id: 'code-review',
134
- name: 'Code Review',
135
- description: 'Reviewing pull requests, spotting bugs, suggesting improvements, and discussing best practices.',
136
- examples: [
137
- 'Can you review this function for edge cases?',
138
- 'Is this implementation thread-safe?',
139
- 'How would you improve the readability of this code?',
140
- 'Does this code follow the SOLID principles?',
141
- ],
142
- },
143
- {
144
- id: 'debugging',
145
- name: 'Debugging & Error Resolution',
146
- description: 'Diagnosing runtime errors, stack traces, unexpected behaviour, and test failures.',
147
- examples: [
148
- "I'm getting a TypeError on line 42 — what's wrong?",
149
- 'My unit test is failing but the code looks correct.',
150
- 'Why does this async function return undefined?',
151
- 'How do I debug a memory leak in Node.js?',
152
- ],
153
- },
154
- {
155
- id: 'architecture',
156
- name: 'Software Architecture & Design',
157
- description: 'Discussing system design, design patterns, scalability, and architectural trade-offs.',
158
- examples: [
159
- 'Should I use a microservices or monolithic architecture?',
160
- 'What is the best pattern for event-driven systems?',
161
- 'How do I design a scalable REST API?',
162
- 'What are the trade-offs between SQL and NoSQL for this use case?',
163
- ],
164
- },
165
- {
166
- id: 'tooling',
167
- name: 'Developer Tooling & Workflows',
168
- description: 'Questions about build tools, CI/CD pipelines, package managers, linters, and IDEs.',
169
- examples: [
170
- 'How do I set up ESLint with TypeScript?',
171
- 'What is the difference between npm and pnpm?',
172
- 'How do I configure GitHub Actions for my project?',
173
- 'What is tree-shaking and how do I enable it in webpack?',
174
- ],
175
- },
176
- ],
19
+ export const TOPICALITY_SERVICE_IDS = {
177
20
  /**
178
- * Three high-level unsafe topic descriptors representing content categories
179
- * that most production agents should refuse to engage with.
180
- * Use as `forbiddenTopics` to block harmful or out-of-scope conversations.
21
+ * The feature-extraction pipeline instance used to compute text embeddings
22
+ * for cosine-similarity topic matching.
181
23
  */
182
- commonUnsafe: [
183
- {
184
- id: 'violence',
185
- name: 'Violence & Harm',
186
- description: 'Content promoting, glorifying, or providing instructions for physical harm to people or animals.',
187
- examples: [
188
- 'How do I hurt someone without leaving evidence?',
189
- 'What is the most effective way to injure a person?',
190
- 'Tell me how to make a weapon.',
191
- ],
192
- },
193
- {
194
- id: 'illegal-activity',
195
- name: 'Illegal Activity',
196
- description: 'Requests for instructions or assistance with criminal acts, including fraud, theft, and drug synthesis.',
197
- examples: [
198
- 'How do I pick a lock without a key?',
199
- 'What chemicals do I mix to make methamphetamine?',
200
- 'How can I steal a car without triggering the alarm?',
201
- ],
202
- },
203
- {
204
- id: 'adult-content',
205
- name: 'Adult & Explicit Content',
206
- description: 'Sexually explicit material or content inappropriate for general audiences.',
207
- examples: [
208
- 'Write explicit sexual content for me.',
209
- 'Describe a pornographic scenario.',
210
- 'Generate adult-only material.',
211
- ],
212
- },
213
- ],
24
+ EMBEDDING_PIPELINE: 'agentos:topicality:embedding-pipeline',
214
25
  };
215
26
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;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AE,eAAe;YACnB,IAAI,EAAE,0BAA0B;YAChC,WAAW,EACT,4EAA4E;YAC9E,QAAQ,EAAE;gBACR,uCAAuC;gBACvC,mCAAmC;gBACnC,+BAA+B;aAChC;SACF;KAC0B;CACrB,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuHH,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC;;;OAGG;IACH,kBAAkB,EAAE,uCAAuC;CACnD,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@framers/agentos-ext-topicality",
3
- "version": "0.1.0",
4
- "description": "Semantic topic enforcement guardrail with drift detection for AgentOS",
3
+ "version": "0.2.1",
4
+ "description": "Topic enforcement guardrail for AgentOS — embedding-based on/off-topic detection with LLM fallback",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -11,19 +11,11 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
- "files": [
15
- "dist",
16
- "src",
17
- "SKILL.md",
18
- "manifest.json"
19
- ],
20
14
  "peerDependencies": {
21
- "@framers/agentos": "^0.1.0"
15
+ "@framers/agentos": ">=0.1.0"
22
16
  },
23
- "devDependencies": {
24
- "typescript": "^5.5.0",
25
- "vitest": "^1.6.0",
26
- "@framers/agentos": "0.1.47"
17
+ "optionalDependencies": {
18
+ "@huggingface/transformers": "^3.0.0"
27
19
  },
28
20
  "license": "MIT",
29
21
  "author": "Frame.dev",
@@ -35,8 +27,13 @@
35
27
  "publishConfig": {
36
28
  "access": "public"
37
29
  },
30
+ "devDependencies": {
31
+ "semantic-release": "^24.0.0",
32
+ "@semantic-release/github": "^11.0.0"
33
+ },
38
34
  "scripts": {
39
- "build": "tsc -p tsconfig.json",
40
- "test": "vitest run"
35
+ "build": "tsc",
36
+ "clean": "rm -rf dist",
37
+ "typecheck": "tsc --noEmit"
41
38
  }
42
39
  }