spora 0.7.7 → 0.7.8
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/{autonomy-NNFTM5NW.js → autonomy-ZMFZRXDZ.js} +7 -7
- package/dist/{chunk-BBXHECZ5.js → chunk-6WBIVXOY.js} +1 -1
- package/dist/chunk-6WBIVXOY.js.map +1 -0
- package/dist/{chunk-JIMONWKO.js → chunk-73CWOI44.js} +4 -4
- package/dist/chunk-73CWOI44.js.map +1 -0
- package/dist/{chunk-ZLSDFYBR.js → chunk-AIGSCHZK.js} +2 -2
- package/dist/{chunk-CP6JWCLY.js → chunk-ER6TILYZ.js} +1 -25
- package/dist/{chunk-CP6JWCLY.js.map → chunk-ER6TILYZ.js.map} +1 -1
- package/dist/chunk-OLYPPXKP.js +69 -0
- package/dist/chunk-OLYPPXKP.js.map +1 -0
- package/dist/{chunk-5R4AJZHN.js → chunk-TKGB5LIN.js} +2 -2
- package/dist/chunk-TTDQZI5W.js +1699 -0
- package/dist/chunk-TTDQZI5W.js.map +1 -0
- package/dist/cli.js +28 -28
- package/dist/{client-AR5ZD6S4.js → client-3APKWQ6O.js} +3 -3
- package/dist/{colony-UGVYALOS.js → colony-7GZ2ODF2.js} +2 -2
- package/dist/{heartbeat-WJJSGUAQ.js → heartbeat-CUM7FIHS.js} +23 -7
- package/dist/heartbeat-CUM7FIHS.js.map +1 -0
- package/dist/heartbeat-narrative-B3RD3OPJ.js +11 -0
- package/dist/{init-6HY4ZPFJ.js → init-KL6XSI7E.js} +3 -3
- package/dist/mcp-server.js +20 -20
- package/dist/{memory-DTSLVSQG.js → memory-G4DNIGLT.js} +2 -2
- package/dist/{prompt-builder-ZFUZNQY2.js → prompt-builder-S6PJVEC5.js} +4 -4
- package/dist/{queue-QCGNDHH2.js → queue-YPBUUP22.js} +2 -2
- package/dist/web-chat/chat.html +15 -5
- package/dist/{web-chat-AKUEBSWS.js → web-chat-XNTIDKAS.js} +37 -15
- package/dist/web-chat-XNTIDKAS.js.map +1 -0
- package/dist/{x-client-S2LUVEKV.js → x-client-2HFEHHVE.js} +2 -2
- package/dist/x-client-2HFEHHVE.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-BBXHECZ5.js.map +0 -1
- package/dist/chunk-JIMONWKO.js.map +0 -1
- package/dist/chunk-TTM54LQR.js +0 -2769
- package/dist/chunk-TTM54LQR.js.map +0 -1
- package/dist/heartbeat-WJJSGUAQ.js.map +0 -1
- package/dist/web-chat-AKUEBSWS.js.map +0 -1
- /package/dist/{autonomy-NNFTM5NW.js.map → autonomy-ZMFZRXDZ.js.map} +0 -0
- /package/dist/{chunk-ZLSDFYBR.js.map → chunk-AIGSCHZK.js.map} +0 -0
- /package/dist/{chunk-5R4AJZHN.js.map → chunk-TKGB5LIN.js.map} +0 -0
- /package/dist/{client-AR5ZD6S4.js.map → client-3APKWQ6O.js.map} +0 -0
- /package/dist/{colony-UGVYALOS.js.map → colony-7GZ2ODF2.js.map} +0 -0
- /package/dist/{memory-DTSLVSQG.js.map → heartbeat-narrative-B3RD3OPJ.js.map} +0 -0
- /package/dist/{init-6HY4ZPFJ.js.map → init-KL6XSI7E.js.map} +0 -0
- /package/dist/{prompt-builder-ZFUZNQY2.js.map → memory-G4DNIGLT.js.map} +0 -0
- /package/dist/{queue-QCGNDHH2.js.map → prompt-builder-S6PJVEC5.js.map} +0 -0
- /package/dist/{x-client-S2LUVEKV.js.map → queue-YPBUUP22.js.map} +0 -0
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runAutonomyCycle
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-TTDQZI5W.js";
|
|
4
|
+
import "./chunk-TKGB5LIN.js";
|
|
5
5
|
import {
|
|
6
6
|
flushQueue
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AIGSCHZK.js";
|
|
8
8
|
import {
|
|
9
9
|
buildReflectionPrompt
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-73CWOI44.js";
|
|
11
11
|
import {
|
|
12
12
|
applyStrategyUpdate,
|
|
13
13
|
loadStrategy,
|
|
14
14
|
saveStrategy
|
|
15
15
|
} from "./chunk-OTZNHIXT.js";
|
|
16
16
|
import "./chunk-CAWWG3MD.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-ER6TILYZ.js";
|
|
18
|
+
import {
|
|
19
|
+
buildHeartbeatNarrative,
|
|
20
|
+
saveHeartbeatNarrative
|
|
21
|
+
} from "./chunk-OLYPPXKP.js";
|
|
18
22
|
import {
|
|
19
23
|
loadIdentity
|
|
20
24
|
} from "./chunk-IULO3GRE.js";
|
|
@@ -30,7 +34,7 @@ import {
|
|
|
30
34
|
} from "./chunk-QYFNAGNI.js";
|
|
31
35
|
import {
|
|
32
36
|
addLearning
|
|
33
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-6WBIVXOY.js";
|
|
34
38
|
import {
|
|
35
39
|
ensureDirectories,
|
|
36
40
|
paths
|
|
@@ -188,6 +192,18 @@ async function runHeartbeat(maxActions, heartbeatCount) {
|
|
|
188
192
|
logger.warn(`Queue flush failed: ${error.message}`);
|
|
189
193
|
}
|
|
190
194
|
const cycle = await runAutonomyCycle(maxActions, heartbeatCount);
|
|
195
|
+
const narrative = buildHeartbeatNarrative({
|
|
196
|
+
heartbeatCount,
|
|
197
|
+
timelineCount: cycle.timeline.length,
|
|
198
|
+
mentionsCount: cycle.mentions.length,
|
|
199
|
+
actions: cycle.actions,
|
|
200
|
+
results: cycle.results
|
|
201
|
+
});
|
|
202
|
+
saveHeartbeatNarrative(
|
|
203
|
+
narrative.summary,
|
|
204
|
+
cycle.results.length === 0 ? true : cycle.results.every((r) => r.success)
|
|
205
|
+
);
|
|
206
|
+
logger.info(`Narrative: ${narrative.summary}`);
|
|
191
207
|
logger.info(`Observed ${cycle.timeline.length} timeline posts and ${cycle.mentions.length} mentions.`);
|
|
192
208
|
if (cycle.actions.length === 0) {
|
|
193
209
|
logger.info("Planner returned no approved actions.");
|
|
@@ -250,4 +266,4 @@ export {
|
|
|
250
266
|
requestStop,
|
|
251
267
|
startHeartbeatLoop
|
|
252
268
|
};
|
|
253
|
-
//# sourceMappingURL=heartbeat-
|
|
269
|
+
//# sourceMappingURL=heartbeat-CUM7FIHS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/heartbeat.ts","../src/runtime/telemetry.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync, readFileSync } from \"node:fs\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadConfig } from \"../utils/config.js\";\nimport { paths } from \"../utils/paths.js\";\nimport { flushQueue } from \"../scheduler/queue.js\";\nimport { runAutonomyCycle } from \"./autonomy.js\";\nimport { writeHeartbeatMetrics } from \"./telemetry.js\";\nimport { buildReflectionPrompt } from \"./prompt-builder.js\";\nimport { generateResponse } from \"./llm.js\";\nimport { addLearning } from \"../memory/index.js\";\nimport { applyStrategyUpdate, loadStrategy, saveStrategy } from \"../memory/strategy.js\";\nimport { loadIdentity } from \"../identity/index.js\";\nimport { buildHeartbeatNarrative, saveHeartbeatNarrative } from \"./heartbeat-narrative.js\";\n\nlet running = false;\n\nexport function isRunning(): boolean {\n return running;\n}\n\nexport function requestStop(): void {\n writeFileSync(paths.stopSignal, \"stop\");\n logger.info(\"Stop signal sent.\");\n}\n\nfunction shouldStop(): boolean {\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n return true;\n }\n return false;\n}\n\nfunction writePid(): void {\n writeFileSync(paths.runtimePid, String(process.pid));\n}\n\nfunction clearPid(): void {\n if (existsSync(paths.runtimePid)) {\n unlinkSync(paths.runtimePid);\n }\n}\n\nexport function getRunningPid(): number | null {\n if (!existsSync(paths.runtimePid)) return null;\n const pid = parseInt(readFileSync(paths.runtimePid, \"utf-8\").trim(), 10);\n if (isNaN(pid)) return null;\n\n // Check if process is actually running\n try {\n process.kill(pid, 0);\n return pid;\n } catch {\n // Process not running, clean up stale PID\n clearPid();\n return null;\n }\n}\n\nexport async function startHeartbeatLoop(): Promise<void> {\n // Check if already running\n const existingPid = getRunningPid();\n if (existingPid) {\n throw new Error(`Spora is already running (PID ${existingPid}). Run \\`spora stop\\` first.`);\n }\n\n running = true;\n writePid();\n\n const config = loadConfig();\n const intervalMs = config.runtime?.heartbeatIntervalMs ?? 300_000;\n const maxActions = config.runtime?.actionsPerHeartbeat ?? 3;\n\n logger.info(`Spora agent starting. Heartbeat interval: ${intervalMs / 1000}s, max actions: ${maxActions}`);\n console.log(`\\nSpora agent is running (PID ${process.pid})`);\n console.log(`Heartbeat every ${Math.round(intervalMs / 60_000)} minutes`);\n console.log(`Press Ctrl+C or run \\`spora stop\\` to stop.\\n`);\n\n // Handle graceful shutdown\n const shutdown = () => {\n logger.info(\"Shutting down...\");\n running = false;\n clearPid();\n process.exit(0);\n };\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n // Clean any stale stop signal\n if (existsSync(paths.stopSignal)) {\n unlinkSync(paths.stopSignal);\n }\n\n let heartbeatCount = 0;\n\n while (running) {\n heartbeatCount++;\n logger.info(`=== Heartbeat #${heartbeatCount} ===`);\n\n try {\n await runHeartbeat(maxActions, heartbeatCount);\n } catch (error) {\n logger.error(\"Heartbeat error\", error);\n console.error(`Heartbeat #${heartbeatCount} failed: ${(error as Error).message}`);\n }\n\n // Check for stop signal\n if (shouldStop()) {\n logger.info(\"Stop signal received.\");\n break;\n }\n\n // Sleep with jitter\n const jitter = Math.floor(Math.random() * intervalMs * 0.3);\n const sleepMs = intervalMs + jitter;\n logger.info(`Sleeping ${Math.round(sleepMs / 1000)}s until next heartbeat...`);\n\n // Sleep in chunks so we can check for stop signals\n const chunkMs = 10_000;\n let slept = 0;\n while (slept < sleepMs && running) {\n await new Promise((r) => setTimeout(r, Math.min(chunkMs, sleepMs - slept)));\n slept += chunkMs;\n if (shouldStop()) {\n running = false;\n break;\n }\n }\n }\n\n clearPid();\n logger.info(\"Spora agent stopped.\");\n console.log(\"\\nSpora agent stopped.\");\n}\n\nasync function runHeartbeat(maxActions: number, heartbeatCount: number): Promise<void> {\n // 1. Flush any queued posts\n logger.info(\"Checking queue...\");\n try {\n const flushed = await flushQueue();\n if (flushed.posted > 0) {\n logger.info(`Flushed ${flushed.posted} queued posts.`);\n }\n } catch (error) {\n logger.warn(`Queue flush failed: ${(error as Error).message}`);\n }\n\n // 2. Run planner/executor cycle.\n const cycle = await runAutonomyCycle(maxActions, heartbeatCount);\n const narrative = buildHeartbeatNarrative({\n heartbeatCount,\n timelineCount: cycle.timeline.length,\n mentionsCount: cycle.mentions.length,\n actions: cycle.actions,\n results: cycle.results,\n });\n saveHeartbeatNarrative(\n narrative.summary,\n cycle.results.length === 0 ? true : cycle.results.every((r) => r.success),\n );\n logger.info(`Narrative: ${narrative.summary}`);\n logger.info(`Observed ${cycle.timeline.length} timeline posts and ${cycle.mentions.length} mentions.`);\n\n if (cycle.actions.length === 0) {\n logger.info(\"Planner returned no approved actions.\");\n return;\n }\n\n logger.info(`Executed ${cycle.results.length} action(s).`);\n\n // 3. Log results\n for (const result of cycle.results) {\n if (result.success) {\n logger.info(` [OK] ${result.action}${result.detail ? `: ${result.detail}` : \"\"}`);\n } else {\n logger.warn(` [FAIL] ${result.action}: ${result.error}`);\n }\n }\n\n for (const note of cycle.policyFeedback) {\n logger.info(` [POLICY] ${note}`);\n }\n\n const metrics = writeHeartbeatMetrics({\n timelineCount: cycle.timeline.length,\n mentionsCount: cycle.mentions.length,\n actions: cycle.actions,\n results: cycle.results,\n policyFeedbackCount: cycle.policyFeedback.length,\n });\n logger.info(\n `Metrics: interactionRatio=${metrics.interactionRatio.toFixed(2)}, repeatedFormatRate=${metrics.repeatedFormatRate.toFixed(2)}`\n );\n\n logger.info(`Heartbeat complete. ${cycle.results.filter((r) => r.success).length}/${cycle.results.length} actions succeeded.`);\n\n // Reflection phase — every 3rd heartbeat\n if (heartbeatCount % 3 === 0) {\n try {\n logger.info(\"Running reflection phase...\");\n const reflectionPrompt = buildReflectionPrompt(cycle.results);\n const reflectionResponse = await generateResponse(\n `You are ${loadIdentity().name}. Reflect honestly on your performance.`,\n reflectionPrompt,\n );\n\n const jsonMatch = reflectionResponse.content.match(/\\{[\\s\\S]*\\}/);\n if (jsonMatch) {\n try {\n const reflection = JSON.parse(jsonMatch[0]);\n if (reflection.learning && reflection.learning !== \"null\") {\n addLearning(reflection.learning, \"reflection\", [\"heartbeat\", \"performance\"]);\n logger.info(`Reflection learning: ${reflection.learning}`);\n }\n if (reflection.strategyUpdate && reflection.strategyUpdate !== \"null\") {\n const strategy = loadStrategy();\n saveStrategy(applyStrategyUpdate(strategy, reflection.strategyUpdate));\n logger.info(`Strategy update: ${reflection.strategyUpdate}`);\n }\n } catch {\n // Couldn't parse reflection JSON\n }\n }\n } catch (err) {\n logger.warn(`Reflection failed: ${(err as Error).message}`);\n }\n }\n}\n","import { appendFileSync } from \"node:fs\";\nimport { paths, ensureDirectories } from \"../utils/paths.js\";\nimport type { AgentAction, ActionResult } from \"./decision-engine.js\";\n\nexport interface HeartbeatMetrics {\n timestamp: string;\n timelineCount: number;\n mentionsCount: number;\n actionCount: number;\n successCount: number;\n postCount: number;\n interactionCount: number;\n interactionRatio: number;\n repeatedFormatRate: number;\n policyRejectionCount: number;\n}\n\nfunction normalize(text: string): string {\n return text.toLowerCase().replace(/[^a-z0-9\\s]/g, \" \").replace(/\\s+/g, \" \").trim();\n}\n\nfunction prefix(text: string, n = 6): string {\n return normalize(text).split(\" \").filter(Boolean).slice(0, n).join(\" \");\n}\n\nfunction repeatedFormatRate(actions: AgentAction[]): number {\n const posts = actions\n .filter((action) => action.action === \"post\" && action.content)\n .map((action) => action.content ?? \"\");\n\n if (posts.length <= 1) return 0;\n\n const seen = new Map<string, number>();\n for (const content of posts) {\n const key = prefix(content);\n seen.set(key, (seen.get(key) ?? 0) + 1);\n }\n\n let repeated = 0;\n for (const count of seen.values()) {\n if (count > 1) repeated += count;\n }\n\n return repeated / posts.length;\n}\n\nexport function writeHeartbeatMetrics(input: {\n timelineCount: number;\n mentionsCount: number;\n actions: AgentAction[];\n results: ActionResult[];\n policyFeedbackCount: number;\n}): HeartbeatMetrics {\n const interactionCount = input.actions.filter((a) => [\"reply\", \"like\", \"retweet\", \"follow\"].includes(a.action)).length;\n const postCount = input.actions.filter((a) => a.action === \"post\").length;\n const successCount = input.results.filter((r) => r.success).length;\n\n const metrics: HeartbeatMetrics = {\n timestamp: new Date().toISOString(),\n timelineCount: input.timelineCount,\n mentionsCount: input.mentionsCount,\n actionCount: input.actions.length,\n successCount,\n postCount,\n interactionCount,\n interactionRatio: input.actions.length > 0 ? interactionCount / input.actions.length : 0,\n repeatedFormatRate: repeatedFormatRate(input.actions),\n policyRejectionCount: input.policyFeedbackCount,\n };\n\n ensureDirectories();\n appendFileSync(paths.runtimeMetrics, JSON.stringify(metrics) + \"\\n\");\n return metrics;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,YAAY,eAAe,oBAAoB;;;ACApE,SAAS,sBAAsB;AAiB/B,SAAS,UAAU,MAAsB;AACvC,SAAO,KAAK,YAAY,EAAE,QAAQ,gBAAgB,GAAG,EAAE,QAAQ,QAAQ,GAAG,EAAE,KAAK;AACnF;AAEA,SAAS,OAAO,MAAc,IAAI,GAAW;AAC3C,SAAO,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG;AACxE;AAEA,SAAS,mBAAmB,SAAgC;AAC1D,QAAM,QAAQ,QACX,OAAO,CAAC,WAAW,OAAO,WAAW,UAAU,OAAO,OAAO,EAC7D,IAAI,CAAC,WAAW,OAAO,WAAW,EAAE;AAEvC,MAAI,MAAM,UAAU,EAAG,QAAO;AAE9B,QAAM,OAAO,oBAAI,IAA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AM;AAAA,QAC/B,WAAW,aAAa,EAAE,IAAI;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,YAAY,mBAAmB,QAAQ,MAAM,aAAa;AAChE,UAAI,WAAW;AACb,YAAI;AACF,gBAAM,aAAa,KAAK,MAAM,UAAU,CAAC,CAAC;AAC1C,cAAI,WAAW,YAAY,WAAW,aAAa,QAAQ;AACzD,wBAAY,WAAW,UAAU,cAAc,CAAC,aAAa,aAAa,CAAC;AAC3E,mBAAO,KAAK,wBAAwB,WAAW,QAAQ,EAAE;AAAA,UAC3D;AACA,cAAI,WAAW,kBAAkB,WAAW,mBAAmB,QAAQ;AACrE,kBAAM,WAAW,aAAa;AAC9B,yBAAa,oBAAoB,UAAU,WAAW,cAAc,CAAC;AACrE,mBAAO,KAAK,oBAAoB,WAAW,cAAc,EAAE;AAAA,UAC7D;AAAA,QACF,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,aAAO,KAAK,sBAAuB,IAAc,OAAO,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildHeartbeatNarrative,
|
|
3
|
+
saveHeartbeatNarrative
|
|
4
|
+
} from "./chunk-OLYPPXKP.js";
|
|
5
|
+
import "./chunk-6WBIVXOY.js";
|
|
6
|
+
import "./chunk-ZWKTKWS6.js";
|
|
7
|
+
export {
|
|
8
|
+
buildHeartbeatNarrative,
|
|
9
|
+
saveHeartbeatNarrative
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=heartbeat-narrative-B3RD3OPJ.js.map
|
|
@@ -276,7 +276,7 @@ async function loginFlow() {
|
|
|
276
276
|
console.log(chalk.green("\u2713 Logged in!\n"));
|
|
277
277
|
console.log(chalk.gray("Opening chat interface...\n"));
|
|
278
278
|
try {
|
|
279
|
-
const { startWebChat } = await import("./web-chat-
|
|
279
|
+
const { startWebChat } = await import("./web-chat-XNTIDKAS.js");
|
|
280
280
|
await startWebChat();
|
|
281
281
|
} catch (error) {
|
|
282
282
|
console.log(chalk.yellow(`Could not start chat interface: ${error.message}
|
|
@@ -368,7 +368,7 @@ async function showDoneAndOpenChat() {
|
|
|
368
368
|
console.log(chalk.bold.cyan("\u2501\u2501\u2501 Your Spore is Ready! \u2501\u2501\u2501\n"));
|
|
369
369
|
console.log(chalk.gray("Opening chat interface...\n"));
|
|
370
370
|
try {
|
|
371
|
-
const { startWebChat } = await import("./web-chat-
|
|
371
|
+
const { startWebChat } = await import("./web-chat-XNTIDKAS.js");
|
|
372
372
|
await startWebChat();
|
|
373
373
|
} catch (error) {
|
|
374
374
|
console.log(chalk.yellow(`Could not start chat interface: ${error.message}
|
|
@@ -506,4 +506,4 @@ async function runInit(token) {
|
|
|
506
506
|
export {
|
|
507
507
|
runInit
|
|
508
508
|
};
|
|
509
|
-
//# sourceMappingURL=init-
|
|
509
|
+
//# sourceMappingURL=init-KL6XSI7E.js.map
|
package/dist/mcp-server.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
loadLearnings,
|
|
22
22
|
loadRelationships,
|
|
23
23
|
updateRelationship
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6WBIVXOY.js";
|
|
25
25
|
import "./chunk-ZWKTKWS6.js";
|
|
26
26
|
|
|
27
27
|
// src/mcp-server.ts
|
|
@@ -388,7 +388,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
388
388
|
},
|
|
389
389
|
async ({ content }) => {
|
|
390
390
|
try {
|
|
391
|
-
const { getXClient } = await import("./x-client-
|
|
391
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
392
392
|
const client = await getXClient();
|
|
393
393
|
const result = await client.postTweet(content);
|
|
394
394
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -406,7 +406,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
406
406
|
},
|
|
407
407
|
async ({ tweetId, content }) => {
|
|
408
408
|
try {
|
|
409
|
-
const { getXClient } = await import("./x-client-
|
|
409
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
410
410
|
const client = await getXClient();
|
|
411
411
|
const result = await client.replyToTweet(tweetId, content);
|
|
412
412
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -421,7 +421,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
421
421
|
{ tweetId: z.string().describe("The ID of the tweet to like") },
|
|
422
422
|
async ({ tweetId }) => {
|
|
423
423
|
try {
|
|
424
|
-
const { getXClient } = await import("./x-client-
|
|
424
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
425
425
|
const client = await getXClient();
|
|
426
426
|
const result = await client.likeTweet(tweetId);
|
|
427
427
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -436,7 +436,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
436
436
|
{ tweetId: z.string().describe("The ID of the tweet to retweet") },
|
|
437
437
|
async ({ tweetId }) => {
|
|
438
438
|
try {
|
|
439
|
-
const { getXClient } = await import("./x-client-
|
|
439
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
440
440
|
const client = await getXClient();
|
|
441
441
|
const result = await client.retweet(tweetId);
|
|
442
442
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -451,7 +451,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
451
451
|
{ userId: z.string().describe("The user ID or handle to follow") },
|
|
452
452
|
async ({ userId }) => {
|
|
453
453
|
try {
|
|
454
|
-
const { getXClient } = await import("./x-client-
|
|
454
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
455
455
|
const client = await getXClient();
|
|
456
456
|
const result = await client.followUser(userId);
|
|
457
457
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -466,7 +466,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
466
466
|
{ userId: z.string().describe("The user ID or handle to unfollow") },
|
|
467
467
|
async ({ userId }) => {
|
|
468
468
|
try {
|
|
469
|
-
const { getXClient } = await import("./x-client-
|
|
469
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
470
470
|
const client = await getXClient();
|
|
471
471
|
const result = await client.unfollowUser(userId);
|
|
472
472
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -481,7 +481,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
481
481
|
{ count: z.number().optional().describe("Number of tweets to fetch (default 20)") },
|
|
482
482
|
async ({ count }) => {
|
|
483
483
|
try {
|
|
484
|
-
const { getXClient } = await import("./x-client-
|
|
484
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
485
485
|
const client = await getXClient();
|
|
486
486
|
const result = await client.getTimeline({ count: count ?? 20 });
|
|
487
487
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -496,7 +496,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
496
496
|
{ count: z.number().optional().describe("Number of mentions to fetch (default 20)") },
|
|
497
497
|
async ({ count }) => {
|
|
498
498
|
try {
|
|
499
|
-
const { getXClient } = await import("./x-client-
|
|
499
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
500
500
|
const client = await getXClient();
|
|
501
501
|
const result = await client.getMentions({ count: count ?? 20 });
|
|
502
502
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -514,7 +514,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
514
514
|
},
|
|
515
515
|
async ({ query, count }) => {
|
|
516
516
|
try {
|
|
517
|
-
const { getXClient } = await import("./x-client-
|
|
517
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
518
518
|
const client = await getXClient();
|
|
519
519
|
const result = await client.searchTweets(query, { count: count ?? 20 });
|
|
520
520
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -529,7 +529,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
529
529
|
{ handle: z.string().describe("X handle (without @)") },
|
|
530
530
|
async ({ handle }) => {
|
|
531
531
|
try {
|
|
532
|
-
const { getXClient } = await import("./x-client-
|
|
532
|
+
const { getXClient } = await import("./x-client-2HFEHHVE.js");
|
|
533
533
|
const client = await getXClient();
|
|
534
534
|
const result = await client.getProfile(handle);
|
|
535
535
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -547,7 +547,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
547
547
|
},
|
|
548
548
|
async ({ content, scheduledFor }) => {
|
|
549
549
|
try {
|
|
550
|
-
const { addToQueue } = await import("./queue-
|
|
550
|
+
const { addToQueue } = await import("./queue-YPBUUP22.js");
|
|
551
551
|
const entry = addToQueue(content, scheduledFor);
|
|
552
552
|
return {
|
|
553
553
|
content: [
|
|
@@ -565,7 +565,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
565
565
|
{},
|
|
566
566
|
async () => {
|
|
567
567
|
try {
|
|
568
|
-
const { flushQueue } = await import("./queue-
|
|
568
|
+
const { flushQueue } = await import("./queue-YPBUUP22.js");
|
|
569
569
|
const results = await flushQueue();
|
|
570
570
|
return {
|
|
571
571
|
content: [
|
|
@@ -586,7 +586,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
586
586
|
{ message: z.string().optional().describe("Optional message to post to the Colony community") },
|
|
587
587
|
async ({ message }) => {
|
|
588
588
|
try {
|
|
589
|
-
const { colonyCheckin } = await import("./colony-
|
|
589
|
+
const { colonyCheckin } = await import("./colony-7GZ2ODF2.js");
|
|
590
590
|
const result = await colonyCheckin(message);
|
|
591
591
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
592
592
|
} catch (error) {
|
|
@@ -600,7 +600,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
600
600
|
{},
|
|
601
601
|
async () => {
|
|
602
602
|
try {
|
|
603
|
-
const { getColonyMemory } = await import("./colony-
|
|
603
|
+
const { getColonyMemory } = await import("./colony-7GZ2ODF2.js");
|
|
604
604
|
const memory = getColonyMemory();
|
|
605
605
|
return { content: [{ type: "text", text: JSON.stringify(memory, null, 2) }] };
|
|
606
606
|
} catch (error) {
|
|
@@ -614,7 +614,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
614
614
|
{},
|
|
615
615
|
async () => {
|
|
616
616
|
try {
|
|
617
|
-
const { getActivePlans } = await import("./colony-
|
|
617
|
+
const { getActivePlans } = await import("./colony-7GZ2ODF2.js");
|
|
618
618
|
const plans = getActivePlans();
|
|
619
619
|
return {
|
|
620
620
|
content: [
|
|
@@ -637,7 +637,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
637
637
|
},
|
|
638
638
|
async ({ description }) => {
|
|
639
639
|
try {
|
|
640
|
-
const { proposePlan } = await import("./colony-
|
|
640
|
+
const { proposePlan } = await import("./colony-7GZ2ODF2.js");
|
|
641
641
|
const result = await proposePlan(description);
|
|
642
642
|
if (result.success) {
|
|
643
643
|
return {
|
|
@@ -660,7 +660,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
660
660
|
},
|
|
661
661
|
async ({ planId }) => {
|
|
662
662
|
try {
|
|
663
|
-
const { joinPlan } = await import("./colony-
|
|
663
|
+
const { joinPlan } = await import("./colony-7GZ2ODF2.js");
|
|
664
664
|
const result = await joinPlan(planId);
|
|
665
665
|
if (result.success) {
|
|
666
666
|
return { content: [{ type: "text", text: "Joined the plan! Go execute it." }] };
|
|
@@ -679,7 +679,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
679
679
|
},
|
|
680
680
|
async ({ status }) => {
|
|
681
681
|
try {
|
|
682
|
-
const { postStatus } = await import("./colony-
|
|
682
|
+
const { postStatus } = await import("./colony-7GZ2ODF2.js");
|
|
683
683
|
const result = await postStatus(status);
|
|
684
684
|
if (result.success) {
|
|
685
685
|
return { content: [{ type: "text", text: "Status posted to the Colony." }] };
|
|
@@ -696,7 +696,7 @@ Identity saved. Your Spore is alive. Use spora_get_identity to read the full doc
|
|
|
696
696
|
{},
|
|
697
697
|
async () => {
|
|
698
698
|
try {
|
|
699
|
-
const { getTodaysActivity } = await import("./colony-
|
|
699
|
+
const { getTodaysActivity } = await import("./colony-7GZ2ODF2.js");
|
|
700
700
|
const activity = getTodaysActivity();
|
|
701
701
|
return {
|
|
702
702
|
content: [
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
saveLearnings,
|
|
9
9
|
saveRelationships,
|
|
10
10
|
updateRelationship
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6WBIVXOY.js";
|
|
12
12
|
import "./chunk-ZWKTKWS6.js";
|
|
13
13
|
export {
|
|
14
14
|
addLearning,
|
|
@@ -21,4 +21,4 @@ export {
|
|
|
21
21
|
saveRelationships,
|
|
22
22
|
updateRelationship
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=memory-
|
|
24
|
+
//# sourceMappingURL=memory-G4DNIGLT.js.map
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
buildSystemPrompt,
|
|
7
7
|
buildToolDecisionMessage,
|
|
8
8
|
buildTrainingChatPrompt
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-73CWOI44.js";
|
|
10
10
|
import "./chunk-OTZNHIXT.js";
|
|
11
11
|
import "./chunk-CAWWG3MD.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-ER6TILYZ.js";
|
|
13
13
|
import "./chunk-IULO3GRE.js";
|
|
14
14
|
import "./chunk-RSNEVBEI.js";
|
|
15
15
|
import "./chunk-QYFNAGNI.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-6WBIVXOY.js";
|
|
17
17
|
import "./chunk-ZWKTKWS6.js";
|
|
18
18
|
export {
|
|
19
19
|
buildChatPrompt,
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
buildToolDecisionMessage,
|
|
25
25
|
buildTrainingChatPrompt
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=prompt-builder-
|
|
27
|
+
//# sourceMappingURL=prompt-builder-S6PJVEC5.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
addToQueue,
|
|
3
3
|
flushQueue,
|
|
4
4
|
showQueue
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AIGSCHZK.js";
|
|
6
6
|
import "./chunk-RSNEVBEI.js";
|
|
7
7
|
import "./chunk-QYFNAGNI.js";
|
|
8
8
|
import "./chunk-ZWKTKWS6.js";
|
|
@@ -11,4 +11,4 @@ export {
|
|
|
11
11
|
flushQueue,
|
|
12
12
|
showQueue
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=queue-
|
|
14
|
+
//# sourceMappingURL=queue-YPBUUP22.js.map
|
package/dist/web-chat/chat.html
CHANGED
|
@@ -589,8 +589,11 @@
|
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
// ===== Tweet Card =====
|
|
592
|
-
function addTweetCard(text,
|
|
592
|
+
function addTweetCard(text, meta = {}) {
|
|
593
593
|
removeSleepCard();
|
|
594
|
+
const kind = typeof meta.kind === 'string' ? meta.kind : 'Post';
|
|
595
|
+
const status = typeof meta.status === 'string' ? meta.status : '';
|
|
596
|
+
const replyTo = typeof meta.replyTo === 'string' ? meta.replyTo : '';
|
|
594
597
|
const card = document.createElement('div');
|
|
595
598
|
card.className = 'tweet-card';
|
|
596
599
|
|
|
@@ -611,7 +614,7 @@
|
|
|
611
614
|
|
|
612
615
|
const badge = document.createElement('span');
|
|
613
616
|
badge.className = 'tweet-card-badge';
|
|
614
|
-
badge.textContent =
|
|
617
|
+
badge.textContent = kind;
|
|
615
618
|
|
|
616
619
|
header.appendChild(avatar);
|
|
617
620
|
header.appendChild(author);
|
|
@@ -627,12 +630,19 @@
|
|
|
627
630
|
|
|
628
631
|
card.appendChild(header);
|
|
629
632
|
card.appendChild(body);
|
|
633
|
+
if (replyTo) {
|
|
634
|
+
const replyToEl = document.createElement('div');
|
|
635
|
+
replyToEl.className = 'tweet-card-time';
|
|
636
|
+
replyToEl.textContent = `replying to ${replyTo}`;
|
|
637
|
+
card.appendChild(replyToEl);
|
|
638
|
+
}
|
|
630
639
|
card.appendChild(time);
|
|
631
640
|
|
|
632
641
|
if (status) {
|
|
633
642
|
const statusEl = document.createElement('div');
|
|
634
|
-
|
|
635
|
-
statusEl.
|
|
643
|
+
const successLike = /posted|sent|queued|success/i.test(status);
|
|
644
|
+
statusEl.className = `tweet-card-status ${successLike ? 'success' : ''}`;
|
|
645
|
+
statusEl.textContent = status;
|
|
636
646
|
card.appendChild(statusEl);
|
|
637
647
|
}
|
|
638
648
|
|
|
@@ -806,7 +816,7 @@
|
|
|
806
816
|
addNarration(event.content);
|
|
807
817
|
break;
|
|
808
818
|
case 'tweet':
|
|
809
|
-
addTweetCard(event.content, event.meta
|
|
819
|
+
addTweetCard(event.content, event.meta || {});
|
|
810
820
|
break;
|
|
811
821
|
case 'action':
|
|
812
822
|
addNarration(event.content, 'action');
|
|
@@ -233,7 +233,7 @@ async function extractAndSaveLearnings(responseText) {
|
|
|
233
233
|
const learnPattern = /<<LEARN:\s*(.+?)>>/g;
|
|
234
234
|
const matches = [...responseText.matchAll(learnPattern)];
|
|
235
235
|
if (matches.length > 0) {
|
|
236
|
-
const { addLearning } = await import("./memory-
|
|
236
|
+
const { addLearning } = await import("./memory-G4DNIGLT.js");
|
|
237
237
|
for (const match of matches) {
|
|
238
238
|
const learning = match[1].trim();
|
|
239
239
|
addLearning(learning, "web-chat", ["chat", "creator-interaction"]);
|
|
@@ -303,7 +303,7 @@ async function extractAndApplyTraining(responseText) {
|
|
|
303
303
|
console.log(chalk.dim(` [Training] Updated strategy`));
|
|
304
304
|
}
|
|
305
305
|
if (update.learning) {
|
|
306
|
-
const { addLearning } = await import("./memory-
|
|
306
|
+
const { addLearning } = await import("./memory-G4DNIGLT.js");
|
|
307
307
|
addLearning(
|
|
308
308
|
update.learning.content,
|
|
309
309
|
"training-chat",
|
|
@@ -348,7 +348,7 @@ async function extractAndApplyTraining(responseText) {
|
|
|
348
348
|
return responseText.replace(/<<TRAINING:[\s\S]*?>>/g, "").trim();
|
|
349
349
|
}
|
|
350
350
|
async function logChatInteraction(userMessage, agentResponse) {
|
|
351
|
-
const { logInteraction } = await import("./memory-
|
|
351
|
+
const { logInteraction } = await import("./memory-G4DNIGLT.js");
|
|
352
352
|
logInteraction({
|
|
353
353
|
id: `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
354
354
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -361,11 +361,12 @@ async function logChatInteraction(userMessage, agentResponse) {
|
|
|
361
361
|
}
|
|
362
362
|
async function runNarratedHeartbeat(server) {
|
|
363
363
|
const { loadConfig } = await import("./config-MU2ODEO3.js");
|
|
364
|
-
const { flushQueue } = await import("./queue-
|
|
365
|
-
const { runAutonomyCycle } = await import("./autonomy-
|
|
366
|
-
const {
|
|
364
|
+
const { flushQueue } = await import("./queue-YPBUUP22.js");
|
|
365
|
+
const { runAutonomyCycle } = await import("./autonomy-ZMFZRXDZ.js");
|
|
366
|
+
const { buildHeartbeatNarrative, saveHeartbeatNarrative } = await import("./heartbeat-narrative-B3RD3OPJ.js");
|
|
367
|
+
const { buildReflectionPrompt } = await import("./prompt-builder-S6PJVEC5.js");
|
|
367
368
|
const { generateResponse } = await import("./llm-IJBRQ7O2.js");
|
|
368
|
-
const { addLearning } = await import("./memory-
|
|
369
|
+
const { addLearning } = await import("./memory-G4DNIGLT.js");
|
|
369
370
|
const { loadStrategy, saveStrategy, applyStrategyUpdate } = await import("./strategy-R2BMRVJ3.js");
|
|
370
371
|
let heartbeatCount = 0;
|
|
371
372
|
let lastIntervalMs = loadConfig().runtime?.heartbeatIntervalMs ?? 3e5;
|
|
@@ -413,11 +414,23 @@ async function runNarratedHeartbeat(server) {
|
|
|
413
414
|
}
|
|
414
415
|
server.pushAgentEvent("narration", "Observing timeline and planning actions...");
|
|
415
416
|
const cycle = await runAutonomyCycle(maxActions, heartbeatCount);
|
|
417
|
+
const narrative = buildHeartbeatNarrative({
|
|
418
|
+
heartbeatCount,
|
|
419
|
+
timelineCount: cycle.timeline.length,
|
|
420
|
+
mentionsCount: cycle.mentions.length,
|
|
421
|
+
actions: cycle.actions,
|
|
422
|
+
results: cycle.results
|
|
423
|
+
});
|
|
424
|
+
saveHeartbeatNarrative(
|
|
425
|
+
narrative.summary,
|
|
426
|
+
cycle.results.length === 0 ? true : cycle.results.every((r) => r.success)
|
|
427
|
+
);
|
|
428
|
+
server.pushAgentEvent("narration", narrative.summary);
|
|
416
429
|
if (cycle.timeline.length > 0 || cycle.mentions.length > 0) {
|
|
417
430
|
server.pushAgentEvent("narration", `Found ${cycle.timeline.length} timeline posts and ${cycle.mentions.length} mentions`);
|
|
418
431
|
}
|
|
419
432
|
if (cycle.actions.length === 0) {
|
|
420
|
-
server.pushAgentEvent("narration", "
|
|
433
|
+
server.pushAgentEvent("narration", "No actions this heartbeat. Going back to sleep.");
|
|
421
434
|
console.log(chalk.dim(` [Agent] No actions this heartbeat`));
|
|
422
435
|
continue;
|
|
423
436
|
}
|
|
@@ -427,9 +440,14 @@ async function runNarratedHeartbeat(server) {
|
|
|
427
440
|
if (!action) continue;
|
|
428
441
|
if (result.success) {
|
|
429
442
|
if (action.action === "post" && action.content) {
|
|
430
|
-
server.pushAgentEvent("tweet", action.content, { status: "
|
|
443
|
+
server.pushAgentEvent("tweet", action.content, { kind: "Post", status: "Posted to X", tweetId: result.detail });
|
|
431
444
|
} else if (action.action === "reply" && action.content) {
|
|
432
|
-
server.pushAgentEvent("
|
|
445
|
+
server.pushAgentEvent("tweet", action.content, {
|
|
446
|
+
kind: "Reply",
|
|
447
|
+
status: "Reply sent",
|
|
448
|
+
tweetId: result.detail,
|
|
449
|
+
replyTo: action.tweetId
|
|
450
|
+
});
|
|
433
451
|
} else if (action.action === "like") {
|
|
434
452
|
server.pushAgentEvent("action", `Liked a tweet`);
|
|
435
453
|
} else if (action.action === "retweet") {
|
|
@@ -437,14 +455,18 @@ async function runNarratedHeartbeat(server) {
|
|
|
437
455
|
} else if (action.action === "follow") {
|
|
438
456
|
server.pushAgentEvent("action", `Followed @${action.handle}`);
|
|
439
457
|
} else if (action.action === "schedule" && action.content) {
|
|
440
|
-
server.pushAgentEvent("tweet", action.content, {
|
|
458
|
+
server.pushAgentEvent("tweet", action.content, { kind: "Scheduled", status: "Queued" });
|
|
441
459
|
} else {
|
|
442
460
|
server.pushAgentEvent("action", `${action.action}${result.detail ? `: ${result.detail}` : ""}`);
|
|
443
461
|
}
|
|
444
462
|
console.log(chalk.green(` [Agent] \u2713 ${result.action}`));
|
|
445
463
|
} else {
|
|
446
|
-
if (action.action === "post" && action.content) {
|
|
447
|
-
server.pushAgentEvent("tweet", action.content, {
|
|
464
|
+
if ((action.action === "post" || action.action === "reply") && action.content) {
|
|
465
|
+
server.pushAgentEvent("tweet", action.content, {
|
|
466
|
+
kind: action.action === "reply" ? "Reply" : "Post",
|
|
467
|
+
status: `Failed: ${result.error}`,
|
|
468
|
+
replyTo: action.action === "reply" ? action.tweetId : void 0
|
|
469
|
+
});
|
|
448
470
|
} else {
|
|
449
471
|
server.pushAgentEvent("error", `${result.action} failed: ${result.error}`);
|
|
450
472
|
}
|
|
@@ -526,7 +548,7 @@ async function startWebChat() {
|
|
|
526
548
|
server.setMessageHandler(async (message) => {
|
|
527
549
|
try {
|
|
528
550
|
if (!systemPrompt || messageCount % 10 === 0) {
|
|
529
|
-
const { buildTrainingChatPrompt } = await import("./prompt-builder-
|
|
551
|
+
const { buildTrainingChatPrompt } = await import("./prompt-builder-S6PJVEC5.js");
|
|
530
552
|
systemPrompt = buildTrainingChatPrompt();
|
|
531
553
|
}
|
|
532
554
|
messageCount++;
|
|
@@ -609,4 +631,4 @@ export {
|
|
|
609
631
|
openBrowser,
|
|
610
632
|
startWebChat
|
|
611
633
|
};
|
|
612
|
-
//# sourceMappingURL=web-chat-
|
|
634
|
+
//# sourceMappingURL=web-chat-XNTIDKAS.js.map
|