-
Notifications
You must be signed in to change notification settings - Fork 1
Seng/chat prototype #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seng/chat prototype #279
Changes from all commits
ad9f99f
e5d713e
67b4cce
d681935
6ee3313
5611093
ce7526b
a8b504c
cebfc57
50c278e
c58d589
bf2fcf7
5f3bace
8660bc7
eca2c37
a3892ab
1d485f3
f26495a
1b15fbc
31e8c76
365f727
6e3be4a
c515da8
b33e8a8
e4b3fdf
6797932
48afdba
b7e4cec
f104ea7
eec9e12
7fccea4
283999b
4e45656
b92dc22
ebf4b0a
c018ffa
15b9443
8f0db92
93fd5c2
211ddfd
9ef8231
7e26af4
40e9185
2ef1cbc
5db648a
01e7e1c
ab43821
f79b636
ea5014f
39c4d2f
d1c4d9b
61e9b76
7ac791c
9b1b3d7
fcca3e5
0efd14e
5500fdb
e1704d6
6920ec6
d3ea19a
26df331
28404a6
92edc6b
394ebfc
312e679
c61d03c
9e51545
02e53f3
01da75a
8635791
e9c36dd
1976c37
528f6f9
bd1ebcf
2c0bb5f
4e7f555
3719399
c99c487
cf066f6
8a14f69
bd8636e
db8bc5c
05e0c82
9d5b733
534c044
5739771
be45ee2
9e9c10c
1a9dcae
b3e832f
8b4f8ac
bbfdd4a
28abcdb
fd56f01
4133dab
678297f
fd066fe
71d7b19
61aaac7
4c86313
5676ba8
07a20fd
a8dd208
84e2e6d
92e4294
f2cdb42
a886586
81e5019
5f43898
a2ffc61
6d3264a
6d70c4e
50e0158
198d769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
### Rule: tutorials-structure | ||
|
||
Purpose: Define how tutorials are authored and rendered so docs and runnable code stay in sync. | ||
|
||
### Structure | ||
- Narrative pages: `content/Tutorial/<tutorial-id>/step-<n>.mdx` | ||
- Section navigation: `content/Tutorial/meta.json` (list MDX page slugs in order) | ||
- Runnable example project: `examples/<tutorial-id>/` (full project; exclude `node_modules/`, `.uv/`) | ||
- Tutorial code snippets: must be imported from files via `<CodeFromFiles />` | ||
- Other, non-project examples: use regular fenced code blocks in MDX | ||
|
||
### MDX authoring | ||
- Each step MDX must use frontmatter: | ||
- `title`, `description` (recommended: `stepNumber`, `next`, `prev`) | ||
- Import real code from the example project using repo-root-relative paths via `<CodeFromFiles />`: | ||
|
||
```mdx | ||
--- | ||
title: Step 1 — Getting Started | ||
description: Intro step | ||
--- | ||
|
||
<!-- Single snippet --> | ||
<CodeFromFiles snippets={[{ path: "/examples/javascript-sdk/src/agent.ts", lang: "ts", title: "agent.ts" }]} /> | ||
|
||
<!-- Line range --> | ||
<CodeFromFiles snippets={[{ path: "/examples/javascript-sdk/src/agent.ts", lang: "ts", from: 12, to: 48, title: "Handler section" }]} /> | ||
|
||
<!-- Multi-language tabs --> | ||
<CodeFromFiles snippets={[ | ||
{ path: "/examples/javascript-sdk/src/agent.ts", lang: "ts", title: "TypeScript" }, | ||
{ path: "/examples/javascript-sdk-python/src/agent.py", lang: "python", title: "Python" }, | ||
]} title="Agent comparison" /> | ||
``` | ||
|
||
### `<CodeFromFiles />` component | ||
- Available in MDX via the docs page components map | ||
- Props: | ||
- `snippets`: array of `{ path, lang?, from?, to?, title? }` | ||
- `path`: repo-root-relative (must start with `/`), validated and read server-side | ||
- `lang`: language for highlighting (auto-inferred if omitted) | ||
- `from`, `to`: 1-based line range (inclusive) | ||
- `title`: label per tab | ||
- `title` (optional): heading displayed above the tabs | ||
- Renders using shared `CodeBlock` styling and `Tabs` for multiple snippets | ||
|
||
### Example project conventions (`examples/<tutorial-id>/`) | ||
- Include: `package.json`, `tsconfig.json`, `src/**`, optional `README.md`, optional lockfile | ||
- Exclude: `node_modules/` | ||
- Optional hygiene: | ||
- Add `examples/**` to `.eslintignore` if you don’t want repo-wide linting on example sources | ||
- Add `examples/**` to root `tsconfig.json` `exclude` if you don’t want repo-wide type-checks | ||
- Should be runnable in a sandbox (StackBlitz/CodeSandbox) via `package.json` scripts | ||
|
||
### Rendering pipeline | ||
- Fumadocs loads MDX via `lib/source.ts` and `app/(docs)/[[...slug]]/page.tsx` | ||
- `<CodeFromFiles />` reads files at build/server time and renders with `CodeBlock` | ||
|
||
|
||
### Agent compatibility (optional) | ||
- Step API: `GET /api/tutorials/:id/steps/:stepNumber` returns `{ mdx, snippets }`. | ||
- The chat UI replaces each `<CodeFromFiles />` occurrence with one or more fenced code blocks by consuming entries from `snippets` in order. | ||
|
||
### Quality gates (recommended) | ||
- CI verifies: | ||
- All `content/Tutorial/**.mdx` pages referenced by `content/Tutorial/meta.json` build without errors | ||
- All `<CodeFromFiles snippets={[...]}/>` references resolve to existing files | ||
- Optional: the example project type-checks (`tsc --noEmit`) or passes a smoke test | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Agent Configuration | ||
AGENT_BASE_URL=http://127.0.0.1:3500 | ||
AGENT_ID=agent_9ccc5545e93644bd9d7954e632a55a61 | ||
AGENT_QA_ID=agent_9ccc5545e93644bd9d7954e632a55a61 | ||
AGENT_PULSE_ID=agent_ddcb59aa4473f1323be5d9f5fb62b74e | ||
|
||
# Alternative: You can also set the full URL instead of BASE_URL + ID | ||
# AGENT_FULL_URL=http://127.0.0.1:3500/agent_9ccc5545e93644bd9d7954e632a55a61 | ||
# API key can be found in agent-docs .env AGENTUITY_SDK_KEY | ||
AGENTUITY_API_KEY= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ yarn-error.log* | |
.env*.local | ||
.env.local | ||
.env.production | ||
.env | ||
.vercel | ||
next-env.d.ts | ||
.open-next | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ | |
} | ||
}, | ||
"module": "index.ts" | ||
} | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Pulse Agent | ||
|
||
A conversational AI agent for tutorial management built with OpenAI and structured responses. | ||
|
||
## Overview | ||
|
||
Pulse is a friendly AI assistant that helps users discover, start, and navigate through tutorials. It uses OpenAI's GPT-4o-mini with structured response generation to provide both conversational responses and actionable instructions. | ||
|
||
## Architecture | ||
|
||
### Core Components | ||
|
||
- **`index.ts`**: Main agent logic using `generateObject` for structured responses | ||
- **`chat-helpers.ts`**: Conversation history management | ||
- **`tutorial-helpers.ts`**: Tutorial content fetching and formatting | ||
- **`tutorial.ts`**: Tutorial API integration | ||
|
||
Comment on lines
+13
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainDoc/file name mismatch: verify and align component list. The README references chat-helpers.ts and tutorial-helpers.ts, but the PR appears to use context/builder.ts, request/parser.ts, state/*, etc. Please sync names/paths to avoid confusion. Run to verify and list actual files: 🏁 Script executed: #!/bin/bash
fd -a --type f 'agent-pulse' | sort Length of output: 35 🏁 Script executed: #!/bin/bash
# List all files in the agent-pulse agent directory to verify actual filenames
if [ -d agent-docs/src/agents/agent-pulse ]; then
find agent-docs/src/agents/agent-pulse -type f | sort
else
echo "Directory agent-docs/src/agents/agent-pulse not found"
fi Length of output: 681 Align README.md component list with actual agent-pulse files
🧰 Tools🪛 LanguageTool[grammar] ~13-~13: There might be a mistake here. (QB_NEW_EN) [grammar] ~14-~14: There might be a mistake here. (QB_NEW_EN) [grammar] ~15-~15: There might be a mistake here. (QB_NEW_EN) 🤖 Prompt for AI Agents
|
||
### Response Structure | ||
|
||
The agent uses `generateObject` to return structured responses with two parts: | ||
|
||
```typescript | ||
{ | ||
message: string, // Conversational response for the user | ||
actionable?: { // Optional action for the program to execute | ||
type: 'start_tutorial' | 'next_step' | 'previous_step' | 'get_tutorials' | 'none', | ||
tutorialId?: string, | ||
step?: number | ||
} | ||
} | ||
``` | ||
|
||
### How It Works | ||
|
||
1. **User Input**: Agent receives user message and conversation history | ||
2. **LLM Processing**: OpenAI generates structured response with message and optional actionable object | ||
3. **Action Execution**: Program intercepts actionable objects and executes them: | ||
- `get_tutorials`: Fetches available tutorial list | ||
- `start_tutorial`: Fetches real tutorial content from API | ||
- `next_step`/`previous_step`: Navigate through tutorial steps (TODO) | ||
4. **Response**: Returns conversational message plus any additional data (tutorial content, tutorial list, etc.) | ||
|
||
## Key Features | ||
|
||
- **Structured Responses**: Clean separation between conversation and actions | ||
- **Real Tutorial Content**: No hallucinated content - all tutorial data comes from actual APIs | ||
- **Context Awareness**: Maintains conversation history for natural references | ||
- **Extensible Actions**: Easy to add new action types (next step, hints, etc.) | ||
- **Debug Logging**: Comprehensive logging for troubleshooting | ||
|
||
## Example Interactions | ||
|
||
### Starting a Tutorial | ||
**User**: "I want to learn the JavaScript SDK" | ||
|
||
**LLM Response**: | ||
```json | ||
{ | ||
"message": "I'd be happy to help you start the JavaScript SDK tutorial!", | ||
"actionable": { | ||
"type": "start_tutorial", | ||
"tutorialId": "javascript-sdk" | ||
} | ||
} | ||
``` | ||
|
||
**Final Response**: | ||
```json | ||
{ | ||
"response": "I'd be happy to help you start the JavaScript SDK tutorial!", | ||
"tutorialData": { | ||
"type": "tutorial_step", | ||
"tutorialId": "javascript-sdk", | ||
"tutorialTitle": "JavaScript SDK Tutorial", | ||
"currentStep": 1, | ||
"stepContent": "Welcome to the JavaScript SDK tutorial...", | ||
"codeBlock": {...} | ||
}, | ||
"conversationHistory": [...] | ||
} | ||
``` | ||
|
||
### General Conversation | ||
**User**: "What's the difference between TypeScript and JavaScript?" | ||
|
||
**LLM Response**: | ||
```json | ||
{ | ||
"message": "TypeScript is a superset of JavaScript that adds static type checking...", | ||
"actionable": { | ||
"type": "none" | ||
} | ||
} | ||
``` | ||
|
||
## Benefits | ||
|
||
- **Reliable**: No parsing or tool interception needed | ||
- **Extensible**: Easy to add new action types | ||
- **Clean**: Clear separation between conversation and actions | ||
- **Debuggable**: Can see exactly what the LLM wants to do | ||
- **No Hallucination**: Tutorial content comes from real APIs, not LLM generation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { AgentContext } from "@agentuity/sdk"; | ||
|
||
export async function buildSystemPrompt(tutorialContext: string, ctx: AgentContext): Promise<string> { | ||
try { | ||
const systemPrompt = `=== ROLE === | ||
You are Pulse, an AI assistant designed to help developers learn and navigate the Agentuity platform through interactive tutorials and clear guidance. Your primary goal is to assist users with understanding and using the Agentuity SDK effectively. When a user's query is vague, unclear, or lacks specific intent, subtly suggest relevant interactive tutorial to guide them toward learning the platform. For clear, specific questions related to the Agentuity SDK or other topics, provide direct, accurate, and concise answers without mentioning tutorials unless relevant. Always maintain a friendly and approachable tone to encourage engagement. | ||
Your role is to ensure user have a smooth tutorial experience! | ||
When user is asking to move to the next tutorial, simply increment the step for them. | ||
afterrburn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
=== PERSONALITY === | ||
- Friendly and encouraging with light humour | ||
- Patient with learners at all levels | ||
- Clear and concise in explanations | ||
- Enthusiastic about teaching and problem-solving | ||
=== Available Tools or Functions === | ||
You have access to various tools you can use -- use when appropriate! | ||
1. Tutorial management | ||
- startTutorialAtStep: Starting the user off at a specific step of a tutorial. | ||
2. General assistance | ||
- askDocsAgentTool: retrieve Agentuity documentation snippets | ||
afterrburn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
=== TOOL-USAGE RULES (must follow) === | ||
- startTutorialById must only be used when user select a tutorial. If the user starts a new tutorial, the step number should be set to one. Valid step is between 1 and totalSteps of the specific tutorial. | ||
- Treat askDocsAgentTool as a search helper; ignore results you judge irrelevant. | ||
=== RESPONSE STYLE (format guidelines) === | ||
- Begin with a short answer, then elaborate if necessary. | ||
- Add brief comments to complex code; skip obvious lines. | ||
- End with a question when further clarification could help the user. | ||
=== SAFETY & BOUNDARIES === | ||
- If asked for private data or secrets, refuse. | ||
- If the user requests actions outside your capabilities, apologise and explain. | ||
- Keep every response < 400 words | ||
Generate a response to the user query accordingly and try to be helpful | ||
=== CONTEXT === | ||
${tutorialContext} | ||
=== END OF PROMPT === | ||
Stream your reasoning steps clearly.`; | ||
|
||
ctx.logger.debug("Built system prompt with tutorial context"); | ||
return systemPrompt; | ||
} catch (error) { | ||
ctx.logger.error("Failed to build system prompt: %s", error instanceof Error ? error.message : String(error)); | ||
throw error; // Re-throw for centralized handling | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Fix incorrect "module" entry; prefer proper ESM/CJS exports over pointing to TypeScript source
"module": "index.ts"
points to TS source, which many bundlers/loaders won’t resolve. Since this package is"type": "module"
and private, either remove"module"
or publish built artifacts and use an"exports"
map (plus"types"
if needed).Example exports map (adjust paths to your actual build output):
{
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
}
}
Also verify
"main": "index.js"
actually exists at runtime (build/bundle produces it) to avoid resolution failures.🏁 Script executed:
Length of output: 2299
Remove the incorrect
"module"
entry and configure proper exportsIn agent-docs/package.json, delete
"module": "index.ts"
and add an"exports"
map that points to your built ESM, CJS, and type artifacts (e.g..agentuity/index.mjs
,.agentuity/index.cjs
,.agentuity/index.d.ts
). Also ensure that"main": "index.js"
matches an actual output file at runtime.🤖 Prompt for AI Agents