@spekra.in/agent-os 0.0.0-stage → 1.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.
Files changed (115) hide show
  1. package/Booker/README.md +41 -0
  2. package/Booker/package.json +11 -0
  3. package/Booker/src/agent.js +15 -0
  4. package/Booker/src/calendar-adapter.js +75 -0
  5. package/Booker/src/index.js +4 -0
  6. package/Booker/src/intake-parser.js +96 -0
  7. package/Booker/src/validation.js +34 -0
  8. package/Booker/test/booker.test.js +35 -0
  9. package/CashHound/README.md +181 -0
  10. package/CashHound/package.json +21 -0
  11. package/CashHound/src/agent.js +621 -0
  12. package/CashHound/src/bank-reconciler.js +66 -0
  13. package/CashHound/src/dunning.js +380 -0
  14. package/CashHound/src/index.js +32 -0
  15. package/CashHound/src/invoice.js +371 -0
  16. package/CashHound/src/mobile.js +35 -0
  17. package/CashHound/src/npv-optimizer.js +259 -0
  18. package/CashHound/test/advanced.test.js +44 -0
  19. package/CashHound/test/cashhound.test.js +530 -0
  20. package/CashHound/test/mobile.test.js +25 -0
  21. package/CashHound/test/security.test.js +35 -0
  22. package/Clerk/README.md +30 -0
  23. package/Clerk/package.json +11 -0
  24. package/Clerk/src/agent.js +18 -0
  25. package/Clerk/src/index.js +2 -0
  26. package/Clerk/src/reconciliation.js +52 -0
  27. package/Clerk/test/clerk.test.js +39 -0
  28. package/LocalRoar/README.md +37 -0
  29. package/LocalRoar/package.json +13 -0
  30. package/LocalRoar/src/agent.js +70 -0
  31. package/LocalRoar/src/booking-router.js +74 -0
  32. package/LocalRoar/src/feedback-interceptor.js +47 -0
  33. package/LocalRoar/src/index.js +7 -0
  34. package/LocalRoar/src/lead-engine.js +52 -0
  35. package/LocalRoar/src/mobile.js +23 -0
  36. package/LocalRoar/src/review-booster.js +24 -0
  37. package/LocalRoar/src/route-density.js +46 -0
  38. package/LocalRoar/test/advanced.test.js +41 -0
  39. package/LocalRoar/test/localroar.test.js +59 -0
  40. package/LocalRoar/test/mobile.test.js +12 -0
  41. package/OmniLife/README.md +39 -0
  42. package/OmniLife/package.json +13 -0
  43. package/OmniLife/src/agent.js +47 -0
  44. package/OmniLife/src/bill-negotiator.js +43 -0
  45. package/OmniLife/src/browser-cancel.js +28 -0
  46. package/OmniLife/src/conflict-engine.js +49 -0
  47. package/OmniLife/src/index.js +6 -0
  48. package/OmniLife/src/mobile.js +18 -0
  49. package/OmniLife/src/subscription-manager.js +66 -0
  50. package/OmniLife/test/advanced.test.js +29 -0
  51. package/OmniLife/test/mobile.test.js +12 -0
  52. package/OmniLife/test/omnilife.test.js +71 -0
  53. package/PulseMD/README.md +42 -0
  54. package/PulseMD/package.json +13 -0
  55. package/PulseMD/src/agent.js +67 -0
  56. package/PulseMD/src/ambient-scribe.js +46 -0
  57. package/PulseMD/src/auth.js +63 -0
  58. package/PulseMD/src/charting.js +54 -0
  59. package/PulseMD/src/index.js +7 -0
  60. package/PulseMD/src/mobile.js +18 -0
  61. package/PulseMD/src/prior-auth.js +39 -0
  62. package/PulseMD/src/safety-guard.js +88 -0
  63. package/PulseMD/test/advanced.test.js +50 -0
  64. package/PulseMD/test/mobile.test.js +12 -0
  65. package/PulseMD/test/pulsemd.test.js +71 -0
  66. package/README.md +208 -2
  67. package/ResolveX/README.md +274 -0
  68. package/ResolveX/package.json +20 -0
  69. package/ResolveX/src/agent.js +679 -0
  70. package/ResolveX/src/carrier-listener.js +405 -0
  71. package/ResolveX/src/diagnosis.js +315 -0
  72. package/ResolveX/src/index.js +36 -0
  73. package/ResolveX/src/mobile.js +31 -0
  74. package/ResolveX/src/policy.js +325 -0
  75. package/ResolveX/src/vision.js +384 -0
  76. package/ResolveX/test/advanced.test.js +445 -0
  77. package/ResolveX/test/mobile.test.js +15 -0
  78. package/ResolveX/test/resolvex.test.js +428 -0
  79. package/SentinelMesh/README.md +51 -0
  80. package/SentinelMesh/package.json +13 -0
  81. package/SentinelMesh/src/governor.js +61 -0
  82. package/SentinelMesh/src/index.js +4 -0
  83. package/SentinelMesh/src/mobile.js +19 -0
  84. package/SentinelMesh/src/policy.js +63 -0
  85. package/SentinelMesh/src/sandbox.js +152 -0
  86. package/SentinelMesh/test/mobile.test.js +12 -0
  87. package/SentinelMesh/test/sentinel.test.js +135 -0
  88. package/Sidekick/README.md +43 -0
  89. package/Sidekick/package.json +11 -0
  90. package/Sidekick/src/agent.js +15 -0
  91. package/Sidekick/src/evidence.js +45 -0
  92. package/Sidekick/src/index.js +3 -0
  93. package/Sidekick/src/validation.js +15 -0
  94. package/Sidekick/test/sidekick.test.js +33 -0
  95. package/agent-os-mobile/README.md +26 -0
  96. package/agent-os-mobile/src/api.js +97 -0
  97. package/agent-os-mobile/src/biometric.js +41 -0
  98. package/agent-os-mobile/src/components/ApprovalStack.js +207 -0
  99. package/agent-os-mobile/src/components/OutcomeCard.js +98 -0
  100. package/agent-os-mobile/src/memory-graph.js +114 -0
  101. package/agent-os-mobile/src/screens/CashHoundMobileScreen.js +111 -0
  102. package/agent-os-mobile/src/screens/LocalRoarMobileScreen.js +183 -0
  103. package/agent-os-mobile/src/screens/OmniLifeMobileScreen.js +111 -0
  104. package/agent-os-mobile/src/screens/PulseMDMobileScreen.js +55 -0
  105. package/agent-os-mobile/src/screens/ResolveXMobileScreen.js +96 -0
  106. package/agent-os-mobile/src/screens/SentinelMeshMobileScreen.js +199 -0
  107. package/agent-os-mobile/src/self-healer.js +104 -0
  108. package/agent-os-mobile/src/speculative-verifier.js +69 -0
  109. package/agent-os-mobile/src/spekra-bridge.js +216 -0
  110. package/agent-os-mobile/src/swarm.js +72 -0
  111. package/agent-os-mobile/src/voice.js +51 -0
  112. package/bin/agentos.js +338 -0
  113. package/package.json +52 -4
  114. package/src/index.js +95 -0
  115. package/src/llm-gateway.js +226 -0
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@spekra.in/agent-os",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "AgentOS Autonomous Multi-Agent Swarm Runtime and Governance SDK for Spekra.in",
5
+ "main": "src/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "agentos": "bin/agentos.js"
9
+ },
10
+ "exports": {
11
+ ".": "./src/index.js",
12
+ "./cli": "./bin/agentos.js"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "src",
20
+ "CashHound",
21
+ "ResolveX",
22
+ "SentinelMesh",
23
+ "LocalRoar",
24
+ "PulseMD",
25
+ "OmniLife",
26
+ "Booker",
27
+ "Sidekick",
28
+ "Clerk",
29
+ "agent-os-mobile/src",
30
+ "README.md"
31
+ ],
32
+ "scripts": {
33
+ "start": "node server.js",
34
+ "doctor": "node bin/agentos.js doctor",
35
+ "fleet": "node bin/agentos.js fleet",
36
+ "swarm": "node bin/agentos.js swarm",
37
+ "ai": "node bin/agentos.js ai",
38
+ "audit": "node bin/agentos.js audit",
39
+ "test": "node --test test/*.test.js agent-os-mobile/test/*.test.js CashHound/test/**/*.test.js ResolveX/test/*.test.js SentinelMesh/test/*.test.js LocalRoar/test/*.test.js PulseMD/test/*.test.js OmniLife/test/*.test.js Booker/test/*.test.js Sidekick/test/*.test.js Clerk/test/*.test.js",
40
+ "test:all": "for dir in agent-os-mobile CashHound ResolveX SentinelMesh LocalRoar PulseMD OmniLife Booker Sidekick Clerk; do (cd \"$dir\" && npm test); done",
41
+ "mobile": "cd agent-os-mobile && npm start"
42
+ },
43
+ "keywords": [
44
+ "agent-os",
45
+ "spekra",
46
+ "autonomous-agents",
47
+ "swarm-intelligence",
48
+ "zero-trust-governance",
49
+ "speculative-verifier",
50
+ "mobile-agent-cockpit"
51
+ ],
52
+ "author": "Subash Thiruppathy",
53
+ "license": "MIT"
54
+ }
package/src/index.js ADDED
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @spekra.in/agent-os
3
+ * The Autonomous Multi-Agent Operating System & Swarm Runtime for Spekra.in
4
+ *
5
+ * Core Modules Exported:
6
+ * - SpeculativeVerifier: Pre-flight math and tone compliance checks
7
+ * - AgentMemoryGraph & MemoryPrivacyTier: Cross-agent graph with zero-trust privacy tiers
8
+ * - AgentSelfHealer & FaultSignature: Autonomous backoff retries & rail switching
9
+ * - SpekraTelemetryBridge: W3C OpenTelemetry trace generator & mirrored ledger
10
+ * - AgentOSSwarm: Multi-agent pipeline orchestrator
11
+ * - BiometricController: Mobile biometric authorization challenge generator
12
+ * - VoiceCockpit: Ambient voice command interpreter and speech synthesizer
13
+ * - SentinelGovernor & PermissionScope: Zero-trust RBAC and quarantine manager
14
+ * - Domain Agents: CashHound, ResolveX, LocalRoar, PulseMD, OmniLife, Booker, Clerk, Sidekick
15
+ */
16
+
17
+ // Mobile & Core Engine Primitives
18
+ export {
19
+ AgentOSLLMGateway
20
+ } from './llm-gateway.js';
21
+
22
+ export {
23
+ SpeculativeVerifier,
24
+ PROHIBITED_COLLECTION_PATTERNS
25
+ } from '../agent-os-mobile/src/speculative-verifier.js';
26
+
27
+ export {
28
+ AgentMemoryGraph,
29
+ MemoryPrivacyTier
30
+ } from '../agent-os-mobile/src/memory-graph.js';
31
+
32
+ export {
33
+ AgentSelfHealer,
34
+ FaultSignature
35
+ } from '../agent-os-mobile/src/self-healer.js';
36
+
37
+ export {
38
+ SpekraTelemetryBridge
39
+ } from '../agent-os-mobile/src/spekra-bridge.js';
40
+
41
+ export {
42
+ AgentOSSwarm
43
+ } from '../agent-os-mobile/src/swarm.js';
44
+
45
+ export {
46
+ BiometricController
47
+ } from '../agent-os-mobile/src/biometric.js';
48
+
49
+ export {
50
+ VoiceCockpit
51
+ } from '../agent-os-mobile/src/voice.js';
52
+
53
+ // Zero-Trust Mesh & Governance
54
+ export {
55
+ SentinelGovernor,
56
+ PermissionScope
57
+ } from '../SentinelMesh/src/index.js';
58
+
59
+ // Autonomous Domain Agents
60
+ export {
61
+ CashHoundAgent,
62
+ Invoice
63
+ } from '../CashHound/src/index.js';
64
+
65
+ export {
66
+ ResolveXAgent
67
+ } from '../ResolveX/src/index.js';
68
+
69
+ export {
70
+ LocalRoarAgent
71
+ } from '../LocalRoar/src/index.js';
72
+
73
+ export {
74
+ PulseMDAgent
75
+ } from '../PulseMD/src/index.js';
76
+
77
+ export {
78
+ OmniLifeAgent
79
+ } from '../OmniLife/src/index.js';
80
+
81
+ export {
82
+ parseIntake,
83
+ CalendarAdapter
84
+ } from '../Booker/src/index.js';
85
+
86
+ export {
87
+ settlementAgent,
88
+ SettlementReconciler
89
+ } from '../Clerk/src/index.js';
90
+
91
+ export {
92
+ fieldAgent,
93
+ EvidenceRegistry,
94
+ reportSchema
95
+ } from '../Sidekick/src/index.js';
@@ -0,0 +1,226 @@
1
+ /**
2
+ * @spekra.in/agent-os
3
+ * AgentOS LLM Gateway & Speculative Guardrail
4
+ *
5
+ * Integrates Google Gemini models (e.g. gemini-2.5-flash) into the AgentOS
6
+ * autonomous swarm with mandatory Speculative Verifier and SentinelMesh
7
+ * pre-flight governance.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { SpeculativeVerifier } from '../agent-os-mobile/src/speculative-verifier.js';
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = path.dirname(__filename);
17
+
18
+ function tryLoadEnv() {
19
+ if (process.env.GEMINI_API_KEY) return;
20
+ const candidates = [
21
+ path.resolve(process.cwd(), '.env'),
22
+ path.resolve(process.cwd(), 'agent-os/.env'),
23
+ path.resolve(__dirname, '../.env'),
24
+ path.resolve(__dirname, '../../.env')
25
+ ];
26
+ for (const envPath of candidates) {
27
+ if (fs.existsSync(envPath)) {
28
+ try {
29
+ const lines = fs.readFileSync(envPath, 'utf8').split('\n');
30
+ for (const line of lines) {
31
+ const match = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
32
+ if (match && !process.env[match[1]]) {
33
+ let value = match[2] || '';
34
+ if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1);
35
+ if (value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
36
+ process.env[match[1]] = value.trim();
37
+ }
38
+ }
39
+ } catch {}
40
+ break;
41
+ }
42
+ }
43
+ }
44
+ tryLoadEnv();
45
+
46
+ export class AgentOSLLMGateway {
47
+ constructor(options = {}) {
48
+ this.apiKey = options.apiKey !== undefined ? options.apiKey : (process.env.GEMINI_API_KEY || null);
49
+ this.model = options.model || process.env.GEMINI_MODEL || 'gemini-3.5-flash';
50
+ this.apiBaseUrl = options.apiBaseUrl || 'https://generativelanguage.googleapis.com/v1beta/models';
51
+ this.verifier = options.verifier || new SpeculativeVerifier();
52
+ this.customFetch = options.fetch || (typeof fetch !== 'undefined' ? fetch : null);
53
+ }
54
+
55
+ get isConfigured() {
56
+ return Boolean(this.apiKey && this.apiKey.length > 0);
57
+ }
58
+
59
+ /**
60
+ * Generates empathetic, FDCPA-compliant dunning & settlement communications.
61
+ */
62
+ async generateDunningNotice({ invoiceId, customerName, amountCents, daysPastDue, tone = 'friendly', discountPercent = 0 }) {
63
+ const discountedTotal = discountPercent > 0
64
+ ? Math.round(amountCents * (1 - discountPercent / 100))
65
+ : amountCents;
66
+
67
+ let generatedText = '';
68
+ let usedProvider = 'deterministic';
69
+
70
+ if (this.isConfigured && this.customFetch) {
71
+ try {
72
+ const prompt = `You are CashHound, an autonomous financial intelligence agent for Spekra.in.
73
+ Generate a concise, professional, non-coercive debt resolution notice for:
74
+ Customer: ${customerName}
75
+ Invoice: ${invoiceId}
76
+ Balance: $${(amountCents / 100).toFixed(2)}
77
+ Days Past Due: ${daysPastDue}
78
+ Tone: ${tone}
79
+ ${discountPercent > 0 ? `Settlement Offer: ${discountPercent}% discount if paid within 7 days ($${(discountedTotal / 100).toFixed(2)} total)` : ''}
80
+ Rule: STRICTLY comply with FDCPA. Never mention arrests, police, jail, or property seizure.`;
81
+
82
+ const resp = await this.customFetch(`${this.apiBaseUrl}/${this.model}:generateContent?key=${this.apiKey}`, {
83
+ method: 'POST',
84
+ headers: { 'Content-Type': 'application/json' },
85
+ body: JSON.stringify({
86
+ contents: [{ parts: [{ text: prompt }] }]
87
+ })
88
+ });
89
+
90
+ if (resp.ok) {
91
+ const data = await resp.json();
92
+ generatedText = data?.candidates?.[0]?.content?.parts?.[0]?.text?.trim() || '';
93
+ usedProvider = `gemini (${this.model})`;
94
+ }
95
+ } catch {
96
+ // Fall back cleanly to deterministic template on any network/API hitch
97
+ }
98
+ }
99
+
100
+ if (!generatedText) {
101
+ usedProvider = 'deterministic-fallback';
102
+ if (discountPercent > 0) {
103
+ generatedText = `Hi ${customerName}, we value our partnership and would like to help resolve invoice ${invoiceId}. As a special accommodation, we can settle your $${(amountCents / 100).toFixed(2)} balance for $${(discountedTotal / 100).toFixed(2)} (${discountPercent}% savings) if paid this week.`;
104
+ } else {
105
+ generatedText = `Hi ${customerName}, this is a gentle reminder that invoice ${invoiceId} ($${(amountCents / 100).toFixed(2)}) is ${daysPastDue} days past due. Please review your account or schedule an installment plan at your earliest convenience.`;
106
+ }
107
+ }
108
+
109
+ // Speculative Verifier Guardrail: pre-flight safety check
110
+ const candidateAction = {
111
+ id: `act-dunning-${invoiceId}`,
112
+ amountCents: discountedTotal,
113
+ breakdown: [{ amountCents: discountedTotal }],
114
+ title: `Dunning Notice (${tone})`,
115
+ description: generatedText
116
+ };
117
+
118
+ const audit = this.verifier.verifyAction(candidateAction);
119
+
120
+ return {
121
+ success: audit.verified,
122
+ provider: usedProvider,
123
+ text: generatedText,
124
+ amountCents: discountedTotal,
125
+ audit,
126
+ guarded: true
127
+ };
128
+ }
129
+
130
+ /**
131
+ * Generates FHIR SOAP notes from multi-speaker clinical dialogues.
132
+ */
133
+ async generateClinicalSoap({ encounterId, clinicianName, patientName, dialogueTurns = [] }) {
134
+ const rawTranscript = dialogueTurns.map(t => `${t.speaker}: ${t.text}`).join('\n');
135
+ let structuredSoap = null;
136
+ let usedProvider = 'deterministic';
137
+
138
+ if (this.isConfigured && this.customFetch) {
139
+ try {
140
+ const prompt = `You are PulseMD, an autonomous clinical charting agent for Spekra.in.
141
+ Extract a clinical SOAP note from this doctor-patient dialogue:
142
+ Clinician: ${clinicianName}
143
+ Patient: ${patientName}
144
+ Dialogue:
145
+ ${rawTranscript}
146
+
147
+ Return JSON with structure: { "subjective": "...", "objective": "...", "assessment": "...", "plan": "...", "suspectedAllergies": [] }`;
148
+
149
+ const resp = await this.customFetch(`${this.apiBaseUrl}/${this.model}:generateContent?key=${this.apiKey}`, {
150
+ method: 'POST',
151
+ headers: { 'Content-Type': 'application/json' },
152
+ body: JSON.stringify({
153
+ contents: [{ parts: [{ text: prompt }] }],
154
+ generationConfig: { responseMimeType: 'application/json' }
155
+ })
156
+ });
157
+
158
+ if (resp.ok) {
159
+ const data = await resp.json();
160
+ const text = data?.candidates?.[0]?.content?.parts?.[0]?.text;
161
+ structuredSoap = JSON.parse(text);
162
+ usedProvider = `gemini (${this.model})`;
163
+ }
164
+ } catch {
165
+ // Fall back cleanly
166
+ }
167
+ }
168
+
169
+ if (!structuredSoap) {
170
+ usedProvider = 'deterministic-fallback';
171
+ const patientStatements = dialogueTurns.filter(t => t.speaker === 'PATIENT').map(t => t.text).join(' ');
172
+ structuredSoap = {
173
+ subjective: `Patient reports: ${patientStatements.slice(0, 150)}...`,
174
+ objective: 'Vitals stable. Physical exam reveals localized tenderness without acute distress.',
175
+ assessment: 'Uncomplicated acute presentation consistent with reported symptom history.',
176
+ plan: 'Hydration, rest, symptom-targeted therapy. Follow up in 7 days if unresolved.',
177
+ suspectedAllergies: []
178
+ };
179
+ }
180
+
181
+ return {
182
+ encounterId,
183
+ provider: usedProvider,
184
+ soap: structuredSoap,
185
+ status: 'AWAITING_CLINICIAN_DUAL_CONTROL_SIGNATURE',
186
+ phiSafe: true
187
+ };
188
+ }
189
+
190
+ /**
191
+ * Generates autonomous multi-stage customer dispute resolution battlecards.
192
+ */
193
+ async generateDisputeResolution({ disputeId, customerText, purchaseAmountCents, warrantyDaysRemaining }) {
194
+ const isUnderWarranty = warrantyDaysRemaining > 0;
195
+ const canAutonomousRefund = purchaseAmountCents <= 10000; // <= $100
196
+ let resolutionType = '';
197
+ let explanation = '';
198
+
199
+ if (isUnderWarranty) {
200
+ resolutionType = canAutonomousRefund ? 'FULL_REFUND_AUTONOMOUS' : 'ESCALATE_TO_SUPERVISOR_FOR_HIGH_VALUE';
201
+ explanation = `Warranty valid (${warrantyDaysRemaining} days remaining). ${canAutonomousRefund ? 'Amount is within autonomous ceiling ($100).' : 'Amount exceeds autonomous ceiling, requiring human dual-control.'}`;
202
+ } else {
203
+ resolutionType = 'STORE_CREDIT_ACCOMMODATION';
204
+ explanation = 'Item is past warranty expiration window; offering customer satisfaction loyalty credit.';
205
+ }
206
+
207
+ const candidateAction = {
208
+ id: `act-dispute-${disputeId}`,
209
+ amountCents: canAutonomousRefund ? purchaseAmountCents : 0,
210
+ breakdown: canAutonomousRefund ? [{ amountCents: purchaseAmountCents }] : [],
211
+ title: `Dispute Resolution (${resolutionType})`,
212
+ description: `${explanation} Customer complaint: ${customerText}`
213
+ };
214
+
215
+ const audit = this.verifier.verifyAction(candidateAction);
216
+
217
+ return {
218
+ disputeId,
219
+ resolutionType,
220
+ explanation,
221
+ refundCents: canAutonomousRefund ? purchaseAmountCents : 0,
222
+ requiresHumanSignoff: !canAutonomousRefund || !isUnderWarranty,
223
+ audit
224
+ };
225
+ }
226
+ }