@stackbilt/aegis-core 0.7.0 → 0.8.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/package.json +13 -3
- package/public/assets/index-CQHn03rW.css +1 -0
- package/public/assets/index-CTKpNJEr.js +74 -0
- package/public/index.html +14 -0
- package/src/adapters/voice/cloudflare-agent.ts +0 -0
- package/src/agent-routing.ts +38 -0
- package/src/assets.ts +6 -0
- package/src/auth.ts +1 -0
- package/src/bluesky.ts +0 -0
- package/src/claude-tools/content.ts +0 -0
- package/src/claude-tools/email.ts +0 -0
- package/src/codebeast.ts +0 -0
- package/src/content/column.ts +0 -0
- package/src/content/hero-image.ts +0 -0
- package/src/content/index.ts +0 -0
- package/src/content/journal.ts +0 -0
- package/src/content/roundtable.ts +0 -0
- package/src/contracts/agenda-item.contract.ts +0 -0
- package/src/contracts/cc-task.contract.ts +0 -0
- package/src/contracts/goal.contract.ts +0 -0
- package/src/contracts/memory-entry.contract.ts +0 -0
- package/src/dashboard.ts +0 -0
- package/src/decision-docs.ts +0 -0
- package/src/dispatch.ts +0 -0
- package/src/edge-env.ts +0 -0
- package/src/exports.ts +0 -0
- package/src/github-projects.ts +0 -0
- package/src/index.ts +7 -1
- package/src/kernel/argus-actions.ts +0 -0
- package/src/kernel/argus-correlation.ts +0 -0
- package/src/kernel/board.ts +0 -0
- package/src/kernel/classify-memory-topic.ts +0 -0
- package/src/kernel/executor-port.ts +0 -0
- package/src/kernel/executor-router.ts +0 -0
- package/src/kernel/grounding/fabrication-detector.ts +0 -0
- package/src/kernel/grounding/fanout.ts +0 -0
- package/src/kernel/grounding/semantic-sanhedrin.ts +0 -0
- package/src/kernel/grounding/verify.ts +0 -0
- package/src/kernel/grounding-layer.ts +0 -0
- package/src/kernel/insight-cache.ts +0 -0
- package/src/kernel/memory/insights.ts +0 -0
- package/src/kernel/memory-guardrails.ts +0 -0
- package/src/kernel/memory-service.ts +0 -0
- package/src/kernel/patterns.ts +0 -0
- package/src/kernel/port.ts +0 -0
- package/src/kernel/provider-factory.ts +0 -0
- package/src/kernel/resilience.ts +0 -0
- package/src/kernel/scheduled/agent-dispatch.ts +0 -0
- package/src/kernel/scheduled/argus-analytics.ts +0 -0
- package/src/kernel/scheduled/argus-heartbeat.ts +0 -0
- package/src/kernel/scheduled/argus-notify.ts +0 -0
- package/src/kernel/scheduled/board-sync.ts +0 -0
- package/src/kernel/scheduled/ci-watcher.ts +0 -0
- package/src/kernel/scheduled/content-drip.ts +0 -0
- package/src/kernel/scheduled/content.ts +0 -0
- package/src/kernel/scheduled/cost-report.ts +0 -0
- package/src/kernel/scheduled/dev-activity.ts +0 -0
- package/src/kernel/scheduled/dreaming/agenda-triage.ts +0 -0
- package/src/kernel/scheduled/dreaming/facts.ts +0 -0
- package/src/kernel/scheduled/dreaming/index.ts +0 -0
- package/src/kernel/scheduled/dreaming/pattern-synthesis.ts +0 -0
- package/src/kernel/scheduled/dreaming/persona.ts +0 -0
- package/src/kernel/scheduled/dreaming/symbolic.ts +0 -0
- package/src/kernel/scheduled/dreaming/task-proposals.ts +0 -0
- package/src/kernel/scheduled/entropy.ts +0 -0
- package/src/kernel/scheduled/feed-watcher.ts +0 -0
- package/src/kernel/scheduled/inbox-processor.ts +0 -0
- package/src/kernel/scheduled/issue-proposer.ts +0 -0
- package/src/kernel/scheduled/issue-watcher.ts +0 -0
- package/src/kernel/scheduled/pr-automerge.ts +0 -0
- package/src/kernel/scheduled/product-health.ts +0 -0
- package/src/kernel/scheduled/self-improvement.ts +0 -0
- package/src/kernel/scheduled/task-audit.ts +0 -0
- package/src/landing.ts +0 -0
- package/src/lib/audit-chain/chain.ts +0 -0
- package/src/lib/audit-chain/types.ts +0 -0
- package/src/lib/observability/errors.ts +0 -0
- package/src/operator/config.ts +0 -0
- package/src/operator/persona.ts +0 -0
- package/src/pulse.ts +0 -0
- package/src/routes/bluesky.ts +0 -0
- package/src/routes/codebeast.ts +0 -0
- package/src/routes/content.ts +0 -0
- package/src/routes/dynamic-tools.ts +0 -0
- package/src/routes/health.ts +1 -0
- package/src/routes/messages.ts +11 -6
- package/src/routes/observability.ts +0 -0
- package/src/routes/operator-logs.ts +0 -0
- package/src/routes/pages.ts +9 -1
- package/src/schema-enums.ts +0 -0
- package/src/task-intelligence.ts +0 -0
- package/src/types.ts +2 -0
- package/src/ui/index.html +13 -0
- package/src/ui/main.tsx +356 -0
- package/src/ui/styles.css +391 -0
- package/src/version.ts +1 -1
- package/src/wiki/client.ts +0 -0
- package/src/wiki/types.ts +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta name="theme-color" content="#101317" />
|
|
7
|
+
<title>AEGIS</title>
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CTKpNJEr.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CQHn03rW.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { routeAgentRequest } from 'agents';
|
|
2
|
+
import type { Env } from './types.js';
|
|
3
|
+
|
|
4
|
+
export async function routeAegisAgentRequest(
|
|
5
|
+
request: Request,
|
|
6
|
+
env: Env,
|
|
7
|
+
): Promise<Response | undefined> {
|
|
8
|
+
const { pathname } = new URL(request.url);
|
|
9
|
+
if (!pathname.startsWith('/agents/')) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const token = extractBearer(request.headers.get('Authorization'))
|
|
14
|
+
?? getCookie(request.headers.get('Cookie') ?? '', 'aegis_token')
|
|
15
|
+
?? new URL(request.url).searchParams.get('token');
|
|
16
|
+
|
|
17
|
+
if (!token || token !== env.AEGIS_TOKEN) {
|
|
18
|
+
return new Response('Unauthorized', { status: 401 });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const response = await routeAgentRequest(request, env);
|
|
23
|
+
return response ?? new Response('Agent route not found', { status: 404 });
|
|
24
|
+
} catch (err) {
|
|
25
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
return new Response(`Agent route failed: ${message}`, { status: 503 });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function extractBearer(header: string | null): string | null {
|
|
31
|
+
if (!header?.startsWith('Bearer ')) return null;
|
|
32
|
+
return header.slice(7);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getCookie(cookieHeader: string, name: string): string | null {
|
|
36
|
+
const match = cookieHeader.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
|
|
37
|
+
return match?.[1] ?? null;
|
|
38
|
+
}
|
package/src/assets.ts
ADDED
package/src/auth.ts
CHANGED
|
@@ -7,6 +7,7 @@ export async function bearerAuth(c: Context<{ Bindings: Env }>, next: Next): Pro
|
|
|
7
7
|
c.req.path === '/health' ||
|
|
8
8
|
c.req.path === '/pulse' ||
|
|
9
9
|
((c.req.path === '/' || c.req.path === '/chat' || c.req.path === '/manifest.json' || c.req.path === '/sw.js') && c.req.method === 'GET') ||
|
|
10
|
+
(c.req.method === 'GET' && (c.req.path.startsWith('/assets/') || c.req.path === '/favicon.svg')) ||
|
|
10
11
|
c.req.path.startsWith('/tech') ||
|
|
11
12
|
c.req.path === '/api/feedback' ||
|
|
12
13
|
c.req.path === '/observe' ||
|
package/src/bluesky.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/codebeast.ts
CHANGED
|
File without changes
|
package/src/content/column.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/content/index.ts
CHANGED
|
File without changes
|
package/src/content/journal.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/dashboard.ts
CHANGED
|
File without changes
|
package/src/decision-docs.ts
CHANGED
|
File without changes
|
package/src/dispatch.ts
CHANGED
|
File without changes
|
package/src/edge-env.ts
CHANGED
|
File without changes
|
package/src/exports.ts
CHANGED
|
File without changes
|
package/src/github-projects.ts
CHANGED
|
File without changes
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { Hono } from 'hono';
|
|
10
10
|
import OAuthProvider from '@cloudflare/workers-oauth-provider';
|
|
11
11
|
import { bearerAuth } from './auth.js';
|
|
12
|
+
import { routeAegisAgentRequest } from './agent-routing.js';
|
|
12
13
|
import { runScheduledTasks } from './kernel/scheduled/index.js';
|
|
13
14
|
import type { Env } from './types.js';
|
|
14
15
|
import { handleMcpRequest } from './mcp-server.js';
|
|
@@ -84,10 +85,15 @@ const oauthProvider = new OAuthProvider<Env>({
|
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
export default {
|
|
87
|
-
fetch:
|
|
88
|
+
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
|
89
|
+
const agentResponse = await routeAegisAgentRequest(request, env);
|
|
90
|
+
if (agentResponse) return agentResponse;
|
|
91
|
+
return oauthProvider.fetch(request, env, ctx);
|
|
92
|
+
},
|
|
88
93
|
async scheduled(_event: ScheduledEvent, env: Env, ctx: ExecutionContext): Promise<void> {
|
|
89
94
|
ctx.waitUntil(runScheduledTasks(buildEdgeEnv(env)));
|
|
90
95
|
},
|
|
91
96
|
};
|
|
92
97
|
|
|
93
98
|
export { ChatSession } from './durable-objects/chat-session.js';
|
|
99
|
+
export { AegisVoiceAdapter } from './adapters/voice/cloudflare-agent.js';
|
|
File without changes
|
|
File without changes
|
package/src/kernel/board.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/kernel/patterns.ts
CHANGED
|
File without changes
|
package/src/kernel/port.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/kernel/resilience.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/landing.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/operator/config.ts
CHANGED
|
File without changes
|
package/src/operator/persona.ts
CHANGED
|
File without changes
|
package/src/pulse.ts
CHANGED
|
File without changes
|
package/src/routes/bluesky.ts
CHANGED
|
File without changes
|
package/src/routes/codebeast.ts
CHANGED
|
File without changes
|
package/src/routes/content.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/routes/health.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { healthPage, type HealthData } from '../health-page.js';
|
|
|
7
7
|
/** Allow consuming apps to override the reported version (set by createAegisApp). */
|
|
8
8
|
let appVersion: string | undefined;
|
|
9
9
|
export function setAppVersion(v: string): void { appVersion = v; }
|
|
10
|
+
export function getAppVersion(): string { return appVersion ?? VERSION; }
|
|
10
11
|
|
|
11
12
|
interface CostHealthEntry {
|
|
12
13
|
spend_usd: number;
|
package/src/routes/messages.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { bodyLimit } from 'hono/body-limit';
|
|
|
3
3
|
import { createIntent, dispatch, dispatchStream } from '../kernel/dispatch.js';
|
|
4
4
|
import { askGroq } from '../groq.js';
|
|
5
5
|
import type { Env, MessageMetadata } from '../types.js';
|
|
6
|
+
import type { Executor } from '../kernel/types.js';
|
|
6
7
|
import { buildEdgeEnv } from '../edge-env.js';
|
|
7
8
|
|
|
8
9
|
// 100 KB — generous for chat text, blocks payload abuse
|
|
@@ -47,7 +48,7 @@ async function generateConversationTitle(
|
|
|
47
48
|
|
|
48
49
|
// ─── Send Message (edge-native kernel) ───────────────────────
|
|
49
50
|
messages.post('/api/message', bodyLimit({ maxSize: MESSAGE_BODY_LIMIT }), async (c) => {
|
|
50
|
-
const body = await c.req.json<{ text: string; conversationId?: string }>();
|
|
51
|
+
const body = await c.req.json<{ text: string; conversationId?: string; executor?: Executor }>();
|
|
51
52
|
if (!body.text?.trim()) {
|
|
52
53
|
return c.json({ error: 'text is required' }, 400);
|
|
53
54
|
}
|
|
@@ -80,7 +81,7 @@ messages.post('/api/message', bodyLimit({ maxSize: MESSAGE_BODY_LIMIT }), async
|
|
|
80
81
|
).bind(userMessageId, conversationId, 'user', text).run();
|
|
81
82
|
|
|
82
83
|
// Fire-and-forget title generation for new conversations (#21)
|
|
83
|
-
if (isNewConversation && c.executionCtx) {
|
|
84
|
+
if (isNewConversation && c.executionCtx && c.env.GROQ_API_KEY) {
|
|
84
85
|
c.executionCtx.waitUntil(
|
|
85
86
|
generateConversationTitle(c.env.DB, conversationId, text, c.env.GROQ_API_KEY, c.env.GROQ_MODEL || 'llama-3.3-70b-versatile', groqBaseUrl(c.env)),
|
|
86
87
|
);
|
|
@@ -88,7 +89,9 @@ messages.post('/api/message', bodyLimit({ maxSize: MESSAGE_BODY_LIMIT }), async
|
|
|
88
89
|
|
|
89
90
|
// Dispatch through edge kernel
|
|
90
91
|
const edgeEnv = buildEdgeEnv(c.env, c.executionCtx);
|
|
91
|
-
const intent = createIntent(conversationId, text
|
|
92
|
+
const intent = createIntent(conversationId, text, {
|
|
93
|
+
forcedExecutor: body.executor,
|
|
94
|
+
});
|
|
92
95
|
|
|
93
96
|
try {
|
|
94
97
|
const result = await dispatch(intent, edgeEnv);
|
|
@@ -146,7 +149,7 @@ messages.post('/api/message', bodyLimit({ maxSize: MESSAGE_BODY_LIMIT }), async
|
|
|
146
149
|
|
|
147
150
|
// ─── Streaming Message (SSE) ─────────────────────────────────
|
|
148
151
|
messages.post('/api/message/stream', bodyLimit({ maxSize: MESSAGE_BODY_LIMIT }), async (c) => {
|
|
149
|
-
const body = await c.req.json<{ text: string; conversationId?: string }>();
|
|
152
|
+
const body = await c.req.json<{ text: string; conversationId?: string; executor?: Executor }>();
|
|
150
153
|
if (!body.text?.trim()) {
|
|
151
154
|
return c.json({ error: 'text is required' }, 400);
|
|
152
155
|
}
|
|
@@ -169,14 +172,16 @@ messages.post('/api/message/stream', bodyLimit({ maxSize: MESSAGE_BODY_LIMIT }),
|
|
|
169
172
|
await c.env.DB.prepare('INSERT INTO messages (id, conversation_id, role, content) VALUES (?, ?, ?, ?)').bind(userMessageId, conversationId, 'user', text).run();
|
|
170
173
|
|
|
171
174
|
// Fire-and-forget title generation for new conversations (#21)
|
|
172
|
-
if (isNewConvStream && c.executionCtx) {
|
|
175
|
+
if (isNewConvStream && c.executionCtx && c.env.GROQ_API_KEY) {
|
|
173
176
|
c.executionCtx.waitUntil(
|
|
174
177
|
generateConversationTitle(c.env.DB, conversationId, text, c.env.GROQ_API_KEY, c.env.GROQ_MODEL || 'llama-3.3-70b-versatile', groqBaseUrl(c.env)),
|
|
175
178
|
);
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
const edgeEnv = buildEdgeEnv(c.env, c.executionCtx);
|
|
179
|
-
const intent = createIntent(conversationId, text
|
|
182
|
+
const intent = createIntent(conversationId, text, {
|
|
183
|
+
forcedExecutor: body.executor,
|
|
184
|
+
});
|
|
180
185
|
|
|
181
186
|
const { readable, writable } = new TransformStream<Uint8Array, Uint8Array>();
|
|
182
187
|
const writer = writable.getWriter();
|
|
File without changes
|
|
File without changes
|
package/src/routes/pages.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
4
|
import { bodyLimit } from 'hono/body-limit';
|
|
5
5
|
import type { Env } from '../types.js';
|
|
6
|
+
import { serveSpaIndex } from '../assets.js';
|
|
6
7
|
import { chatPage } from '../ui.js';
|
|
7
8
|
import { landingPage } from '../landing.js';
|
|
8
9
|
import { dashboardPage, getDashboardData } from '../dashboard.js';
|
|
9
10
|
import { pulsePage, getPulseData } from '../pulse.js';
|
|
11
|
+
import { getAppVersion } from './health.js';
|
|
10
12
|
|
|
11
13
|
const DEFAULT_BODY_LIMIT = 100 * 1024;
|
|
12
14
|
|
|
@@ -15,6 +17,9 @@ const pages = new Hono<{ Bindings: Env }>();
|
|
|
15
17
|
// ─── Landing ────────────────────────────────────────────────
|
|
16
18
|
|
|
17
19
|
pages.get('/', (c) => {
|
|
20
|
+
if (c.env.ASSETS) {
|
|
21
|
+
return serveSpaIndex(c.req.raw, c.env.ASSETS);
|
|
22
|
+
}
|
|
18
23
|
return c.html(chatPage());
|
|
19
24
|
});
|
|
20
25
|
|
|
@@ -25,13 +30,16 @@ pages.get('/about', (c) => {
|
|
|
25
30
|
// ─── Chat ───────────────────────────────────────────────────
|
|
26
31
|
|
|
27
32
|
pages.get('/chat', (c) => {
|
|
33
|
+
if (c.env.ASSETS) {
|
|
34
|
+
return serveSpaIndex(c.req.raw, c.env.ASSETS);
|
|
35
|
+
}
|
|
28
36
|
return c.html(chatPage());
|
|
29
37
|
});
|
|
30
38
|
|
|
31
39
|
// ─── Pulse ──────────────────────────────────────────────────
|
|
32
40
|
|
|
33
41
|
pages.get('/pulse', async (c) => {
|
|
34
|
-
const data = await getPulseData(c.env.DB);
|
|
42
|
+
const data = await getPulseData(c.env.DB, getAppVersion(), c.env.MEMORY);
|
|
35
43
|
return c.html(pulsePage(data));
|
|
36
44
|
});
|
|
37
45
|
|
package/src/schema-enums.ts
CHANGED
|
File without changes
|
package/src/task-intelligence.ts
CHANGED
|
File without changes
|
package/src/types.ts
CHANGED
|
@@ -4,7 +4,9 @@ export interface Env {
|
|
|
4
4
|
DB: D1Database;
|
|
5
5
|
AI: Ai;
|
|
6
6
|
AEGIS_TOKEN: string;
|
|
7
|
+
ASSETS?: Fetcher;
|
|
7
8
|
CHAT_SESSION?: DurableObjectNamespace;
|
|
9
|
+
AegisVoiceAdapter?: DurableObjectNamespace;
|
|
8
10
|
|
|
9
11
|
// OAuth 2.1 (injected by OAuthProvider wrapper at runtime)
|
|
10
12
|
OAUTH_PROVIDER: OAuthHelpers;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta name="theme-color" content="#101317" />
|
|
7
|
+
<title>AEGIS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|