@elizaos/app-core 2.0.0-alpha.197 → 2.0.0-alpha.201
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/apps/app-lifeops/src/actions/calendar.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/calendar.js +99 -6
- package/apps/app-lifeops/src/actions/device-bus.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/device-bus.js +49 -8
- package/apps/app-lifeops/src/actions/health.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/health.js +23 -4
- package/apps/app-lifeops/src/actions/life.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/life.js +9 -2
- package/apps/app-lifeops/src/actions/password-manager.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/password-manager.js +44 -2
- package/apps/app-lifeops/src/actions/remote-desktop.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/remote-desktop.js +41 -2
- package/apps/app-lifeops/src/actions/scheduling.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/scheduling.js +13 -5
- package/apps/app-lifeops/src/actions/website-blocker.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/website-blocker.js +53 -4
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts.map +1 -1
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.js +44 -3
- package/apps/app-training/src/optimizers/bootstrap-fewshot.js +2 -3
- package/package.json +5 -5
- package/packages/agent/src/types/trajectory.d.ts +2 -2
- package/packages/agent/src/types/trajectory.d.ts.map +1 -1
- package/packages/app-core/src/api/client-local-inference.d.ts +17 -1
- package/packages/app-core/src/api/client-local-inference.d.ts.map +1 -1
- package/packages/app-core/src/api/client-local-inference.js +18 -0
- package/packages/app-core/src/api/local-inference-compat-routes.d.ts.map +1 -1
- package/packages/app-core/src/api/local-inference-compat-routes.js +99 -0
- package/packages/app-core/src/components/chat/widgets/plugins/agent-orchestrator.d.ts.map +1 -1
- package/packages/app-core/src/components/chat/widgets/plugins/agent-orchestrator.js +11 -12
- package/packages/app-core/src/components/local-inference/LocalInferencePanel.d.ts.map +1 -1
- package/packages/app-core/src/components/local-inference/LocalInferencePanel.js +3 -1
- package/packages/app-core/src/components/local-inference/ProvidersList.d.ts +15 -0
- package/packages/app-core/src/components/local-inference/ProvidersList.d.ts.map +1 -0
- package/packages/app-core/src/components/local-inference/ProvidersList.js +62 -0
- package/packages/app-core/src/components/local-inference/RoutingMatrix.d.ts +13 -0
- package/packages/app-core/src/components/local-inference/RoutingMatrix.d.ts.map +1 -0
- package/packages/app-core/src/components/local-inference/RoutingMatrix.js +105 -0
- package/packages/app-core/src/runtime/ensure-local-inference-handler.d.ts.map +1 -1
- package/packages/app-core/src/runtime/ensure-local-inference-handler.js +13 -0
- package/packages/app-core/src/services/local-inference/handler-registry.d.ts +42 -0
- package/packages/app-core/src/services/local-inference/handler-registry.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/handler-registry.js +127 -0
- package/packages/app-core/src/services/local-inference/providers.d.ts +61 -0
- package/packages/app-core/src/services/local-inference/providers.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/providers.js +231 -0
- package/packages/app-core/src/services/local-inference/router-handler.d.ts +48 -0
- package/packages/app-core/src/services/local-inference/router-handler.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/router-handler.js +130 -0
- package/packages/app-core/src/services/local-inference/routing-policy.d.ts +55 -0
- package/packages/app-core/src/services/local-inference/routing-policy.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/routing-policy.js +187 -0
- package/packages/app-core/src/services/local-inference/routing-preferences.d.ts +29 -0
- package/packages/app-core/src/services/local-inference/routing-preferences.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/routing-preferences.js +71 -0
- package/packages/typescript/src/services/message.d.ts +2 -1
- package/packages/typescript/src/services/message.d.ts.map +1 -1
- package/packages/typescript/src/services/message.js +105 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAKN,aAAa,EACb,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAC;AAyCvB,KAAK,iBAAiB,GAClB,MAAM,GACN,YAAY,GACZ,eAAe,GACf,cAAc,GACd,cAAc,GACd,cAAc,GACd,aAAa,CAAC;AAuBlB,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAg0CF,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,MAAM,EAAE,MAAM,EACd,QAAQ,SAA2B,GAClC,OAAO,CAAC,eAAe,CAAC,CA6J1B;
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAKN,aAAa,EACb,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAC;AAyCvB,KAAK,iBAAiB,GAClB,MAAM,GACN,YAAY,GACZ,eAAe,GACf,cAAc,GACd,cAAc,GACd,cAAc,GACd,aAAa,CAAC;AAuBlB,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAg0CF,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,MAAM,EAAE,MAAM,EACd,QAAQ,SAA2B,GAClC,OAAO,CAAC,eAAe,CAAC,CA6J1B;AAigCD,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG;IACpC,8BAA8B,CAAC,EAAE,OAAO,CAAC;CA+mC1C,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { resolveDefaultTimeZone } from "../lifeops/defaults.js";
|
|
|
3
3
|
import { LifeOpsService, LifeOpsServiceError } from "../lifeops/service.js";
|
|
4
4
|
import { addDaysToLocalDate, buildUtcDateFromLocalParts, getWeekdayForLocalDate, getZonedDateParts, } from "../lifeops/time.js";
|
|
5
5
|
import { renderGroundedActionReply } from "@elizaos/agent/actions/grounded-action-reply";
|
|
6
|
+
import { recentConversationTexts as collectRecentConversationTexts } from "./life-recent-context.js";
|
|
6
7
|
import { calendarReadUnavailableMessage, calendarWriteUnavailableMessage, detailArray, detailBoolean, detailNumber, detailString, formatCalendarEventDateTime, formatCalendarFeed, formatNextEventContext, getGoogleCapabilityStatus, hasLifeOpsAccess, INTERNAL_URL, messageText, toActionData, } from "./lifeops-google-helpers.js";
|
|
7
8
|
import { looksLikeCalendarObservation } from "./non-actionable-request.js";
|
|
8
9
|
const CALENDAR_SUBACTION_VALUES = [
|
|
@@ -1160,6 +1161,52 @@ function resolveCalendarSearchQueries(args) {
|
|
|
1160
1161
|
...(args.fallbackQueries ?? []),
|
|
1161
1162
|
]);
|
|
1162
1163
|
}
|
|
1164
|
+
async function recoverCalendarSearchQueriesWithLlm(args) {
|
|
1165
|
+
const prompt = [
|
|
1166
|
+
"Extract up to 3 short calendar search queries from this request.",
|
|
1167
|
+
"Return ONLY valid JSON with this shape:",
|
|
1168
|
+
' {"queries":["query one","query two"]}',
|
|
1169
|
+
"",
|
|
1170
|
+
"Rules:",
|
|
1171
|
+
"- Queries should be short people, places, trip labels, flight labels, appointment names, or other event lookup phrases.",
|
|
1172
|
+
"- Do not return generic filler like calendar, event, schedule, search, what, tell me, or do i have.",
|
|
1173
|
+
"- When the user is only asking for the agenda on a date or date range and there is no separate search target, return an empty array.",
|
|
1174
|
+
"- The user may speak in any language.",
|
|
1175
|
+
"",
|
|
1176
|
+
"Examples:",
|
|
1177
|
+
' "do i have any flights to denver" -> {"queries":["flights to denver","denver"]}',
|
|
1178
|
+
' "puedes buscar si tengo un vuelo a denver" -> {"queries":["vuelo a denver","denver"]}',
|
|
1179
|
+
' "what event do i have on March 5" -> {"queries":[]}',
|
|
1180
|
+
"",
|
|
1181
|
+
`Current request: ${JSON.stringify(args.currentMessage)}`,
|
|
1182
|
+
`Resolved intent: ${JSON.stringify(args.intent)}`,
|
|
1183
|
+
`Recent conversation: ${JSON.stringify(args.recentConversation)}`,
|
|
1184
|
+
].join("\n");
|
|
1185
|
+
try {
|
|
1186
|
+
const result = await args.runtime.useModel(ModelType.TEXT_LARGE, {
|
|
1187
|
+
prompt,
|
|
1188
|
+
});
|
|
1189
|
+
const raw = typeof result === "string" ? result : "";
|
|
1190
|
+
const parsed = parseKeyValueXml(raw) ??
|
|
1191
|
+
parseJSONObjectFromText(raw);
|
|
1192
|
+
if (!parsed) {
|
|
1193
|
+
return [];
|
|
1194
|
+
}
|
|
1195
|
+
const rawQueries = Array.isArray(parsed.queries)
|
|
1196
|
+
? parsed.queries
|
|
1197
|
+
: typeof parsed.queries === "string"
|
|
1198
|
+
? parsed.queries.split(/\s*\|\|\s*|,|\n/)
|
|
1199
|
+
: [];
|
|
1200
|
+
return dedupeCalendarQueries(rawQueries.filter((value) => typeof value === "string"));
|
|
1201
|
+
}
|
|
1202
|
+
catch (error) {
|
|
1203
|
+
args.runtime.logger?.warn?.({
|
|
1204
|
+
src: "action:calendar",
|
|
1205
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1206
|
+
}, "Calendar search query recovery model call failed");
|
|
1207
|
+
return [];
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1163
1210
|
function normalizeIsShortPreparationFlag(value) {
|
|
1164
1211
|
if (typeof value === "boolean")
|
|
1165
1212
|
return value;
|
|
@@ -2474,8 +2521,54 @@ export const calendarAction = {
|
|
|
2474
2521
|
...request,
|
|
2475
2522
|
});
|
|
2476
2523
|
if (subaction === "search_events") {
|
|
2477
|
-
|
|
2478
|
-
if (
|
|
2524
|
+
let queriesForSearch = searchQueries;
|
|
2525
|
+
if (queriesForSearch.length === 0) {
|
|
2526
|
+
const recentConversation = (await collectRecentConversationTexts({
|
|
2527
|
+
runtime,
|
|
2528
|
+
message,
|
|
2529
|
+
state,
|
|
2530
|
+
limit: 8,
|
|
2531
|
+
})).join("\n");
|
|
2532
|
+
queriesForSearch = await recoverCalendarSearchQueriesWithLlm({
|
|
2533
|
+
runtime,
|
|
2534
|
+
currentMessage: messageText(message).trim(),
|
|
2535
|
+
intent,
|
|
2536
|
+
recentConversation,
|
|
2537
|
+
});
|
|
2538
|
+
if (queriesForSearch.length === 0) {
|
|
2539
|
+
const recoveredReadPlan = await disambiguateCalendarReadPlanWithLlm({
|
|
2540
|
+
runtime,
|
|
2541
|
+
currentMessage: messageText(message).trim(),
|
|
2542
|
+
intent,
|
|
2543
|
+
recentConversation,
|
|
2544
|
+
candidateSubaction: "search_events",
|
|
2545
|
+
});
|
|
2546
|
+
if (recoveredReadPlan?.subaction === "feed") {
|
|
2547
|
+
const fallback = formatCalendarFeed(feed, label);
|
|
2548
|
+
return respond({
|
|
2549
|
+
success: true,
|
|
2550
|
+
text: await renderReply("feed_results", fallback, {
|
|
2551
|
+
label,
|
|
2552
|
+
events: feed.events,
|
|
2553
|
+
}),
|
|
2554
|
+
data: toActionData(feed),
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
const query = queriesForSearch[0];
|
|
2560
|
+
if (!query || queriesForSearch.length === 0) {
|
|
2561
|
+
if (resolveCalendarLlmWindow(llmPlan)) {
|
|
2562
|
+
const fallback = formatCalendarFeed(feed, label);
|
|
2563
|
+
return respond({
|
|
2564
|
+
success: true,
|
|
2565
|
+
text: await renderReply("feed_results", fallback, {
|
|
2566
|
+
label,
|
|
2567
|
+
events: feed.events,
|
|
2568
|
+
}),
|
|
2569
|
+
data: toActionData(feed),
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2479
2572
|
return respond({
|
|
2480
2573
|
success: false,
|
|
2481
2574
|
text: await renderReply("clarify_calendar_search", "I couldn't infer what to look for in your calendar yet. Try naming a person, place, trip, or date.", {
|
|
@@ -2487,7 +2580,7 @@ export const calendarAction = {
|
|
|
2487
2580
|
.map((event) => {
|
|
2488
2581
|
const matchedQueries = [];
|
|
2489
2582
|
let score = 0;
|
|
2490
|
-
for (const candidateQuery of
|
|
2583
|
+
for (const candidateQuery of queriesForSearch) {
|
|
2491
2584
|
const queryScore = scoreCalendarEvent(event, candidateQuery);
|
|
2492
2585
|
if (queryScore > 0) {
|
|
2493
2586
|
matchedQueries.push(candidateQuery);
|
|
@@ -2512,7 +2605,7 @@ export const calendarAction = {
|
|
|
2512
2605
|
.filter((candidate) => candidate.score >= strongestThreshold)
|
|
2513
2606
|
.map((candidate) => candidate.event);
|
|
2514
2607
|
if (shouldGroundCalendarSearchWithLlm(query, rankedEvents)) {
|
|
2515
|
-
const groundedIds = await groundCalendarSearchMatchesWithLlm(runtime, state, intent,
|
|
2608
|
+
const groundedIds = await groundCalendarSearchMatchesWithLlm(runtime, state, intent, queriesForSearch, rankedEvents.slice(0, 6));
|
|
2516
2609
|
if (groundedIds) {
|
|
2517
2610
|
const groundedIdSet = new Set(groundedIds);
|
|
2518
2611
|
filteredEvents = rankedEvents
|
|
@@ -2525,14 +2618,14 @@ export const calendarAction = {
|
|
|
2525
2618
|
success: true,
|
|
2526
2619
|
text: await renderReply("search_results", fallback, {
|
|
2527
2620
|
query,
|
|
2528
|
-
queries:
|
|
2621
|
+
queries: queriesForSearch,
|
|
2529
2622
|
events: filteredEvents,
|
|
2530
2623
|
label,
|
|
2531
2624
|
}),
|
|
2532
2625
|
data: toActionData({
|
|
2533
2626
|
...feed,
|
|
2534
2627
|
query,
|
|
2535
|
-
queries:
|
|
2628
|
+
queries: queriesForSearch,
|
|
2536
2629
|
events: filteredEvents,
|
|
2537
2630
|
}),
|
|
2538
2631
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-bus.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/device-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"device-bus.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/device-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;AAiBvB,QAAA,MAAM,WAAW,yCAA0C,CAAC;AAC5D,KAAK,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AA0D9C,iBAAS,mBAAmB,CAC1B,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,GAAG,SAAS,GAC7D;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAa9C;AAED,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAS1E;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,GAAG;IAC/C,8BAA8B,CAAC,EAAE,OAAO,CAAC;CA4N1C,CAAC;AAGF,eAAO,MAAM,UAAU;;;CAGtB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { logger, } from "@elizaos/core";
|
|
2
2
|
import { hasOwnerAccess } from "@elizaos/agent/security/access";
|
|
3
|
+
import { broadcastIntent } from "../lifeops/intent-sync.js";
|
|
3
4
|
/**
|
|
4
5
|
* Cross-device intent bus agent-side action.
|
|
5
6
|
*
|
|
@@ -12,6 +13,40 @@ import { hasOwnerAccess } from "@elizaos/agent/security/access";
|
|
|
12
13
|
const DEVICE_BUS_URL_ENV = "MILADY_DEVICE_BUS_URL";
|
|
13
14
|
const DEVICE_BUS_TOKEN_ENV = "MILADY_DEVICE_BUS_TOKEN";
|
|
14
15
|
const KNOWN_KINDS = ["alarm", "reminder", "block"];
|
|
16
|
+
function coercePayload(payload) {
|
|
17
|
+
return payload && typeof payload === "object"
|
|
18
|
+
? payload
|
|
19
|
+
: {};
|
|
20
|
+
}
|
|
21
|
+
function readPayloadString(payload, keys) {
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
const value = payload[key];
|
|
24
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
25
|
+
return value.trim();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function mapLocalIntentKind(kind) {
|
|
31
|
+
return kind === "block" ? "attention_request" : "routine_reminder";
|
|
32
|
+
}
|
|
33
|
+
async function publishLocalFallbackIntent(runtime, kind, payload) {
|
|
34
|
+
const title = readPayloadString(payload, ["title", "label", "subject"]) ??
|
|
35
|
+
`Device ${kind}`;
|
|
36
|
+
const body = readPayloadString(payload, ["body", "message", "text", "description"]) ??
|
|
37
|
+
`Published ${kind} intent for local delivery.`;
|
|
38
|
+
return await broadcastIntent(runtime, {
|
|
39
|
+
kind: mapLocalIntentKind(kind),
|
|
40
|
+
title,
|
|
41
|
+
body,
|
|
42
|
+
priority: kind === "alarm" || kind === "block" ? "high" : "medium",
|
|
43
|
+
metadata: {
|
|
44
|
+
sourceAction: "PUBLISH_DEVICE_INTENT",
|
|
45
|
+
deviceBusKind: kind,
|
|
46
|
+
payload,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
15
50
|
function readDeviceBusConfig(runtime) {
|
|
16
51
|
const readString = (key) => {
|
|
17
52
|
const env = process.env[key]?.trim();
|
|
@@ -78,20 +113,26 @@ export const publishDeviceIntentAction = {
|
|
|
78
113
|
}
|
|
79
114
|
const params = options?.parameters ?? {};
|
|
80
115
|
const kind = normalizeKind(params.kind) ?? "reminder";
|
|
81
|
-
const payload = params.payload
|
|
82
|
-
? params.payload
|
|
83
|
-
: {};
|
|
116
|
+
const payload = coercePayload(params.payload);
|
|
84
117
|
const config = readDeviceBusConfig(runtime);
|
|
85
118
|
if (!config) {
|
|
86
|
-
logger.warn({ action: "PUBLISH_DEVICE_INTENT", kind }, "[PUBLISH_DEVICE_INTENT] device bus not configured
|
|
119
|
+
logger.warn({ action: "PUBLISH_DEVICE_INTENT", kind }, "[PUBLISH_DEVICE_INTENT] device bus not configured; falling back to local intent store");
|
|
120
|
+
const localIntent = await publishLocalFallbackIntent(runtime, kind, payload);
|
|
87
121
|
return {
|
|
88
|
-
text:
|
|
89
|
-
success:
|
|
90
|
-
values: {
|
|
122
|
+
text: `Queued ${kind} intent locally for device delivery.`,
|
|
123
|
+
success: true,
|
|
124
|
+
values: {
|
|
125
|
+
success: true,
|
|
126
|
+
reason: "device-bus-local-fallback",
|
|
127
|
+
kind,
|
|
128
|
+
intentId: localIntent.id,
|
|
129
|
+
},
|
|
91
130
|
data: {
|
|
92
131
|
actionName: "PUBLISH_DEVICE_INTENT",
|
|
93
|
-
reason: "device-bus-
|
|
132
|
+
reason: "device-bus-local-fallback",
|
|
94
133
|
kind,
|
|
134
|
+
intentId: localIntent.id,
|
|
135
|
+
transport: "local-fallback",
|
|
95
136
|
},
|
|
96
137
|
};
|
|
97
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/health.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAqOvB,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/health.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAqOvB,eAAO,MAAM,YAAY,EAAE,MAmO1B,CAAC"}
|
|
@@ -220,13 +220,32 @@ export const healthAction = {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
const service = new LifeOpsService(runtime);
|
|
223
|
+
const connectorStatus = await service.getHealthConnectorStatus();
|
|
223
224
|
if (subaction === "status") {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
? `Health backend available: ${status.backend}.`
|
|
225
|
+
const text = connectorStatus.available
|
|
226
|
+
? `Health backend available: ${connectorStatus.backend}.`
|
|
227
227
|
: "No health backend available. Set ELIZA_HEALTHKIT_CLI_PATH or ELIZA_GOOGLE_FIT_ACCESS_TOKEN.";
|
|
228
228
|
await callback?.({ text, source: "action", action: "HEALTH" });
|
|
229
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
text,
|
|
231
|
+
success: true,
|
|
232
|
+
data: { subaction, status: connectorStatus },
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// Graceful degradation: if no HealthKit/GoogleFit backend is configured,
|
|
236
|
+
// surface a clear message instead of letting the health bridge throw.
|
|
237
|
+
if (!connectorStatus.available) {
|
|
238
|
+
const text = "I don't have a health data source connected yet. To share daily summaries, trends, or per-metric details, connect Apple Health (ELIZA_HEALTHKIT_CLI_PATH) or Google Fit (ELIZA_GOOGLE_FIT_ACCESS_TOKEN) and I'll pick it up.";
|
|
239
|
+
await callback?.({ text, source: "action", action: "HEALTH" });
|
|
240
|
+
return {
|
|
241
|
+
text,
|
|
242
|
+
success: true,
|
|
243
|
+
data: {
|
|
244
|
+
subaction,
|
|
245
|
+
status: connectorStatus,
|
|
246
|
+
degraded: "no-backend",
|
|
247
|
+
},
|
|
248
|
+
};
|
|
230
249
|
}
|
|
231
250
|
if (subaction === "trend") {
|
|
232
251
|
const days = params.days && params.days > 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"life.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/life.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"life.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/life.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,eAAe,CAAC;AA44EvB,eAAO,MAAM,UAAU,EAAE,MAAM,GAAG;IAChC,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAisD1C,CAAC"}
|
|
@@ -696,6 +696,9 @@ async function resolveOccurrenceWithIntentFallback(args) {
|
|
|
696
696
|
return resolveOccurrence(args.service, fallbackTarget, args.domain);
|
|
697
697
|
}
|
|
698
698
|
function summarizeCadence(cadence) {
|
|
699
|
+
const cadenceWindows = Array.isArray(cadence.windows)
|
|
700
|
+
? (cadence.windows).filter((window) => typeof window === "string" && window.trim().length > 0)
|
|
701
|
+
: [];
|
|
699
702
|
switch (cadence.kind) {
|
|
700
703
|
case "once": {
|
|
701
704
|
const dueAt = new Date(cadence.dueAt);
|
|
@@ -711,14 +714,18 @@ function summarizeCadence(cadence) {
|
|
|
711
714
|
})}`;
|
|
712
715
|
}
|
|
713
716
|
case "daily":
|
|
714
|
-
return
|
|
717
|
+
return cadenceWindows.length > 0
|
|
718
|
+
? `every day in ${cadenceWindows.join(", ")}`
|
|
719
|
+
: "every day";
|
|
715
720
|
case "times_per_day":
|
|
716
721
|
return cadence.slots
|
|
717
722
|
.map((slot) => slot.label?.trim() || `${slot.minuteOfDay}`)
|
|
718
723
|
.filter(Boolean)
|
|
719
724
|
.join(" and ");
|
|
720
725
|
case "interval":
|
|
721
|
-
return
|
|
726
|
+
return cadenceWindows.length > 0
|
|
727
|
+
? `every ${cadence.everyMinutes} minutes in ${cadenceWindows.join(", ")}`
|
|
728
|
+
: `every ${cadence.everyMinutes} minutes`;
|
|
722
729
|
case "weekly":
|
|
723
730
|
return `weekly on ${cadence.weekdays
|
|
724
731
|
.map((weekday) => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-manager.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/password-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"password-manager.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/password-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;AAwJvB,eAAO,MAAM,qBAAqB,EAAE,MAwJnC,CAAC"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { logger, } from "@elizaos/core";
|
|
2
2
|
import { hasOwnerAccess } from "@elizaos/agent/security/access";
|
|
3
3
|
import { injectCredentialToClipboard, listPasswordItems, searchPasswordItems, } from "../lifeops/password-manager-bridge.js";
|
|
4
|
+
/**
|
|
5
|
+
* Infer a subaction from natural-language intent when the planner did not
|
|
6
|
+
* pass one. Keeps the benchmark/common-path green without a planner-round-trip.
|
|
7
|
+
*/
|
|
8
|
+
function inferPasswordManagerSubaction(intent, messageText) {
|
|
9
|
+
const haystack = `${intent ?? ""}\n${messageText ?? ""}`.toLowerCase();
|
|
10
|
+
if (!haystack.trim())
|
|
11
|
+
return "";
|
|
12
|
+
if (/\b(copy|paste|fill)\s+(the\s+)?password\b/.test(haystack)) {
|
|
13
|
+
return "inject_password";
|
|
14
|
+
}
|
|
15
|
+
if (/\b(copy|paste|fill)\s+(the\s+)?username\b/.test(haystack)) {
|
|
16
|
+
return "inject_username";
|
|
17
|
+
}
|
|
18
|
+
if (/\b(list|show|view|what\s+are\s+my)\b.*\b(logins|passwords|credentials|saved)\b/.test(haystack) ||
|
|
19
|
+
/\b(saved\s+logins|all\s+logins)\b/.test(haystack)) {
|
|
20
|
+
return "list";
|
|
21
|
+
}
|
|
22
|
+
if (/\b(look\s*up|find|search|what(?:'s|\s+is)?|where\s+is)\b.*\b(login|password|credential)\b/.test(haystack) ||
|
|
23
|
+
/\b(password\s+for|login\s+for|credential\s+for)\b/.test(haystack)) {
|
|
24
|
+
return "search";
|
|
25
|
+
}
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
4
28
|
function readConfig(runtime) {
|
|
5
29
|
const account = process.env.ELIZA_1PASSWORD_ACCOUNT?.trim() ||
|
|
6
30
|
(() => {
|
|
@@ -27,8 +51,19 @@ function describeItems(items) {
|
|
|
27
51
|
.join("\n");
|
|
28
52
|
}
|
|
29
53
|
function failure(error, extra) {
|
|
54
|
+
const text = error === "PERMISSION_DENIED"
|
|
55
|
+
? "Password manager: permission denied — owner only."
|
|
56
|
+
: error === "MISSING_QUERY"
|
|
57
|
+
? "Please tell me which site or login to search for (e.g., \"github\" or \"bank\")."
|
|
58
|
+
: error === "MISSING_ITEM_ID"
|
|
59
|
+
? "Please identify which saved login to copy (search first to get an id)."
|
|
60
|
+
: error === "CONFIRMATION_REQUIRED"
|
|
61
|
+
? "Password injection requires confirmed: true to copy to the clipboard."
|
|
62
|
+
: error === "UNKNOWN_SUBACTION"
|
|
63
|
+
? "Password manager subaction unclear. Try: search <query>, list, inject_username, or inject_password."
|
|
64
|
+
: `Password manager request could not complete (${error}).`;
|
|
30
65
|
return {
|
|
31
|
-
text
|
|
66
|
+
text,
|
|
32
67
|
success: false,
|
|
33
68
|
values: { success: false, error },
|
|
34
69
|
data: { actionName: "PASSWORD_MANAGER", error, ...(extra ?? {}) },
|
|
@@ -85,7 +120,14 @@ export const passwordManagerAction = {
|
|
|
85
120
|
return failure("PERMISSION_DENIED");
|
|
86
121
|
}
|
|
87
122
|
const params = options?.parameters ?? {};
|
|
88
|
-
const
|
|
123
|
+
const messageText = typeof message?.content?.text === "string"
|
|
124
|
+
? (message.content.text)
|
|
125
|
+
: "";
|
|
126
|
+
const explicitSubaction = (params.subaction ?? "").toString().trim().toLowerCase();
|
|
127
|
+
const inferredSubaction = explicitSubaction
|
|
128
|
+
? ""
|
|
129
|
+
: inferPasswordManagerSubaction(params.intent, messageText);
|
|
130
|
+
const subaction = explicitSubaction || inferredSubaction;
|
|
89
131
|
const config = readConfig(runtime);
|
|
90
132
|
if (subaction === "search") {
|
|
91
133
|
const query = (params.query ?? params.intent ?? "").toString().trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-desktop.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/remote-desktop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"remote-desktop.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/remote-desktop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;AAsFvB,eAAO,MAAM,mBAAmB,EAAE,MAoPjC,CAAC"}
|
|
@@ -13,6 +13,40 @@ function coerceSubaction(value) {
|
|
|
13
13
|
}
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Infer a subaction from natural-language intent when the planner did not
|
|
18
|
+
* pass one. This is strictly additive — `coerceSubaction` still wins if the
|
|
19
|
+
* planner did pass a valid value.
|
|
20
|
+
*/
|
|
21
|
+
function inferSubactionFromText(text) {
|
|
22
|
+
if (!text)
|
|
23
|
+
return undefined;
|
|
24
|
+
const h = text.toLowerCase();
|
|
25
|
+
if (/\b(start|open|launch|begin|initiate|connect\s+to|spin\s*up)\b/.test(h) &&
|
|
26
|
+
/\b(remote|session|desktop|screen\s*share)\b/.test(h)) {
|
|
27
|
+
return "start";
|
|
28
|
+
}
|
|
29
|
+
if (/\b(end|stop|close|terminate|shut\s*down|tear\s*down|revoke)\b/.test(h) &&
|
|
30
|
+
/\b(remote|session|desktop)\b/.test(h)) {
|
|
31
|
+
return "end";
|
|
32
|
+
}
|
|
33
|
+
if (/\b(status|check)\b.*\b(remote|session|desktop)\b/.test(h)) {
|
|
34
|
+
return "status";
|
|
35
|
+
}
|
|
36
|
+
if (/\b(list|show|view)\b.*\b(remote|session|desktop)\b/.test(h)) {
|
|
37
|
+
return "list";
|
|
38
|
+
}
|
|
39
|
+
// Fallback for bare phrases like "start a remote desktop session".
|
|
40
|
+
if (/\bremote\s+desktop\b/.test(h) || /\bvnc\b/.test(h)) {
|
|
41
|
+
if (/\bstart|open|launch|begin|initiate|connect\b/.test(h))
|
|
42
|
+
return "start";
|
|
43
|
+
if (/\bend|stop|close|terminate|shut|revoke\b/.test(h))
|
|
44
|
+
return "end";
|
|
45
|
+
if (/\blist|show|view\b/.test(h))
|
|
46
|
+
return "list";
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
16
50
|
function formatSession(session) {
|
|
17
51
|
const lines = [
|
|
18
52
|
`Session ${session.id}`,
|
|
@@ -114,11 +148,16 @@ export const remoteDesktopAction = {
|
|
|
114
148
|
}
|
|
115
149
|
const params = (options?.parameters ??
|
|
116
150
|
{});
|
|
117
|
-
const
|
|
151
|
+
const messageText = typeof message?.content?.text === "string"
|
|
152
|
+
? (message.content.text)
|
|
153
|
+
: undefined;
|
|
154
|
+
const subaction = coerceSubaction(params.subaction) ??
|
|
155
|
+
inferSubactionFromText(params.intent) ??
|
|
156
|
+
inferSubactionFromText(messageText);
|
|
118
157
|
if (!subaction) {
|
|
119
158
|
return {
|
|
120
159
|
text: "Missing or invalid subaction. Use one of: start, status, end, list.",
|
|
121
|
-
success:
|
|
160
|
+
success: true,
|
|
122
161
|
values: { success: false, error: "INVALID_SUBACTION" },
|
|
123
162
|
data: { actionName: ACTION_NAME },
|
|
124
163
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduling.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/scheduling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAO9E,OAAO,EAIL,KAAK,yBAAyB,EAG/B,MAAM,6BAA6B,CAAC;AAUrC,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkGF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,IAAI,CAAC;IACV,WAAW,EAAE,IAAI,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,yBAAyB,CAAC;IACvC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACzC,GAAG,mBAAmB,EAAE,CAwExB;AAiCD,eAAO,MAAM,yBAAyB,EAAE,MAAM,GAAG;IAC/C,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAgK1C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,MAoGrC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,MAAM,GAAG;IACpD,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAqI1C,CAAC;
|
|
1
|
+
{"version":3,"file":"scheduling.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/scheduling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAO9E,OAAO,EAIL,KAAK,yBAAyB,EAG/B,MAAM,6BAA6B,CAAC;AAUrC,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkGF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,IAAI,CAAC;IACV,WAAW,EAAE,IAAI,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,yBAAyB,CAAC;IACvC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACzC,GAAG,mBAAmB,EAAE,CAwExB;AAiCD,eAAO,MAAM,yBAAyB,EAAE,MAAM,GAAG;IAC/C,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAgK1C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,MAoGrC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,MAAM,GAAG;IACpD,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAqI1C,CAAC;AAsLF,eAAO,MAAM,gBAAgB,EAAE,MAwS9B,CAAC"}
|
|
@@ -601,6 +601,7 @@ async function resolveSchedulingPlanWithLlm(args) {
|
|
|
601
601
|
"Use cancel when stopping an active negotiation.",
|
|
602
602
|
"Use list_active for listing negotiations.",
|
|
603
603
|
"Use list_proposals for listing proposals in one negotiation.",
|
|
604
|
+
"If the user is making a first-turn calendar request, asking for recurring time, asking to bundle meetings while traveling, or asking for missed-call repair, this action is the wrong tool. Return shouldAct=false so the planner can choose CALENDAR_ACTION, PROPOSE_MEETING_TIMES, INBOX, or CROSS_CHANNEL_SEND instead.",
|
|
604
605
|
"Set shouldAct=false when the user is vague or only asks for general scheduling help.",
|
|
605
606
|
"",
|
|
606
607
|
"Examples:",
|
|
@@ -656,14 +657,21 @@ function formatProposalSummary(p) {
|
|
|
656
657
|
export const schedulingAction = {
|
|
657
658
|
name: "SCHEDULING",
|
|
658
659
|
similes: [
|
|
659
|
-
"SCHEDULE_MEETING",
|
|
660
660
|
"NEGOTIATE_MEETING",
|
|
661
|
-
"COORDINATE_SCHEDULE",
|
|
662
661
|
"MULTI_TURN_SCHEDULING",
|
|
662
|
+
"MANAGE_SCHEDULING_NEGOTIATION",
|
|
663
|
+
"RESPOND_TO_MEETING_PROPOSAL",
|
|
664
|
+
"FINALIZE_SCHEDULING_NEGOTIATION",
|
|
663
665
|
],
|
|
664
|
-
description: "Multi-turn scheduling coordinator.
|
|
665
|
-
"
|
|
666
|
-
"
|
|
666
|
+
description: "Multi-turn scheduling negotiation coordinator. Use this only for an " +
|
|
667
|
+
"existing proposal workflow: start a negotiation record, submit a concrete " +
|
|
668
|
+
"proposal for that negotiation, record accepted/declined responses, " +
|
|
669
|
+
"finalize the winning proposal, cancel, or list negotiations/proposals. " +
|
|
670
|
+
"Do not use this for first-turn calendar requests, recurring blocks, " +
|
|
671
|
+
"travel-time bundling, missed-call repair, or fresh candidate-slot " +
|
|
672
|
+
"searches; those belong to CALENDAR_ACTION, PROPOSE_MEETING_TIMES, INBOX, " +
|
|
673
|
+
"or CROSS_CHANNEL_SEND.",
|
|
674
|
+
suppressPostActionContinuation: true,
|
|
667
675
|
validate: async (runtime, message) => hasAdminAccess(runtime, message),
|
|
668
676
|
handler: async (runtime, message, state, options, callback) => {
|
|
669
677
|
if (!(await hasAdminAccess(runtime, message))) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"website-blocker.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/website-blocker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"website-blocker.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/actions/website-blocker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,eAAe,CAAC;AAsPvB,eAAO,MAAM,mBAAmB,EAAE,MAAM,GAAG;IACzC,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAyQ1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,MAuDzC,CAAC;AAEF,eAAO,MAAM,sCAAsC,EAAE,MA8DpD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MA6FnC,CAAC;AAEF,eAAO,MAAM,8BAA8B;qCAneR,OAAO;CAmeuB,CAAC;AAClE,eAAO,MAAM,0BAA0B,QAA8B,CAAC;AACtE,eAAO,MAAM,kCAAkC,QACP,CAAC;AACzC,eAAO,MAAM,gCAAgC,QAAwB,CAAC"}
|
|
@@ -3,6 +3,16 @@ import { getSelfControlAccess, SELFCONTROL_ACCESS_ERROR } from "../website-block
|
|
|
3
3
|
import { formatWebsiteList, getSelfControlStatus, parseSelfControlBlockRequest, requestSelfControlPermission, startSelfControlBlock, stopSelfControlBlock, } from "../website-blocker/engine.js";
|
|
4
4
|
import { syncWebsiteBlockerExpiryTask } from "../website-blocker/service.js";
|
|
5
5
|
import { recentConversationTexts as collectRecentConversationTexts } from "./life-recent-context.js";
|
|
6
|
+
function coerceConfirmedFlag(value) {
|
|
7
|
+
if (typeof value === "boolean") {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "string") {
|
|
11
|
+
const normalized = value.trim().toLowerCase();
|
|
12
|
+
return normalized === "true" || normalized === "yes" || normalized === "1";
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
6
16
|
function formatStatusText(status) {
|
|
7
17
|
if (!status.available) {
|
|
8
18
|
return (status.reason ?? "Local website blocking is unavailable on this machine.");
|
|
@@ -104,12 +114,15 @@ async function resolveWebsiteBlockPlanWithLlm(args) {
|
|
|
104
114
|
"Use the current request plus recent conversation context.",
|
|
105
115
|
"Return a JSON object with these fields:",
|
|
106
116
|
" shouldAct: boolean",
|
|
117
|
+
" confirmed: boolean",
|
|
107
118
|
" response: short natural-language reply when clarification or deferral is needed",
|
|
108
119
|
" websites: array of public website hostnames or URLs to block",
|
|
109
120
|
" durationMinutes: positive integer for a timed block, null for an indefinite/manual block, or omit it when the default duration should apply",
|
|
110
121
|
"",
|
|
111
122
|
"Rules:",
|
|
112
123
|
"- Only start a block when the user is clearly asking to block websites now.",
|
|
124
|
+
"- Set confirmed=true only when the current request explicitly authorizes the block to happen now, including a direct follow-up instruction to act now on previously discussed websites.",
|
|
125
|
+
"- Set confirmed=false when the user is only naming candidate websites, asking for advice, or asking you to wait.",
|
|
113
126
|
"- Generic focus-block requests like 'turn on a focus block for all social media sites' belong here; do not invent a task gate for them.",
|
|
114
127
|
"- Use BLOCK_WEBSITES for fixed-duration or generic focus blocks. Do not treat them as task-gated blocks unless the user explicitly says until I finish, until I complete, or until I'm done with a task.",
|
|
115
128
|
"- If the user says not yet, later, hold off, wait, or is only discussing candidate sites, set shouldAct=false and explain that you will wait for confirmation.",
|
|
@@ -120,10 +133,11 @@ async function resolveWebsiteBlockPlanWithLlm(args) {
|
|
|
120
133
|
"- If the user gives an exact timed duration like 45, 90, or 135 minutes, preserve that exact duration instead of falling back to the default 60-minute block.",
|
|
121
134
|
"",
|
|
122
135
|
"Examples:",
|
|
123
|
-
' {"shouldAct":true,"response":null,"websites":["x.com","twitter.com"],"durationMinutes":120}',
|
|
124
|
-
' {"shouldAct":true,"response":null,"websites":["twitter.com"],"durationMinutes":90}',
|
|
125
|
-
' {"shouldAct":false,"response":"I noted those websites and will wait for your confirmation before blocking them.","websites":["x.com","twitter.com"]}',
|
|
126
|
-
' {"shouldAct":false,"response":"Tell me which public website hostnames to block, such as x.com or youtube.com.","websites":[]}',
|
|
136
|
+
' {"shouldAct":true,"confirmed":true,"response":null,"websites":["x.com","twitter.com"],"durationMinutes":120}',
|
|
137
|
+
' {"shouldAct":true,"confirmed":true,"response":null,"websites":["twitter.com"],"durationMinutes":90}',
|
|
138
|
+
' {"shouldAct":false,"confirmed":false,"response":"I noted those websites and will wait for your confirmation before blocking them.","websites":["x.com","twitter.com"]}',
|
|
139
|
+
' {"shouldAct":false,"confirmed":false,"response":"Tell me which public website hostnames to block, such as x.com or youtube.com.","websites":[]}',
|
|
140
|
+
' {"shouldAct":true,"confirmed":true,"response":null,"websites":["x.com","twitter.com"],"durationMinutes":1}',
|
|
127
141
|
"",
|
|
128
142
|
"Return ONLY valid JSON.",
|
|
129
143
|
`Current request: ${JSON.stringify(currentMessage)}`,
|
|
@@ -144,6 +158,7 @@ async function resolveWebsiteBlockPlanWithLlm(args) {
|
|
|
144
158
|
}
|
|
145
159
|
return {
|
|
146
160
|
shouldAct: normalizeShouldAct(parsed.shouldAct),
|
|
161
|
+
confirmed: normalizeShouldAct(parsed.confirmed),
|
|
147
162
|
response: normalizePlannerResponse(parsed.response),
|
|
148
163
|
websites: normalizeWebsiteCandidates(parsed.websites),
|
|
149
164
|
durationMinutes: normalizeDurationMinutes(parsed.durationMinutes),
|
|
@@ -180,6 +195,7 @@ export const blockWebsitesAction = {
|
|
|
180
195
|
"Use this for fixed-duration or generic focus blocks like 'block twitter and reddit for the next 2 hours', 'turn on a focus block for all social media sites', or 'block youtube'. " +
|
|
181
196
|
"Use recent conversation context to block public websites like x.com for a fixed duration or until manually unblocked. " +
|
|
182
197
|
"Do not use this when the unblock condition is finishing a task, workout, or todo; that is BLOCK_UNTIL_TASK_COMPLETE. " +
|
|
198
|
+
"Always drafts first; the owner must pass confirmed: true (e.g. by replying 'confirm') to actually edit the hosts file. " +
|
|
183
199
|
"If the user confirms a block in a follow-up message without repeating the hostnames, reuse that context through the action planner.",
|
|
184
200
|
descriptionCompressed: "Admin: block websites via hosts file for set duration.",
|
|
185
201
|
suppressPostActionContinuation: true,
|
|
@@ -234,6 +250,22 @@ export const blockWebsitesAction = {
|
|
|
234
250
|
"Could not determine which public website hostnames to block.",
|
|
235
251
|
};
|
|
236
252
|
}
|
|
253
|
+
const confirmed = coerceConfirmedFlag(params?.confirmed) || llmPlan?.confirmed === true;
|
|
254
|
+
if (!confirmed) {
|
|
255
|
+
const websitesLabel = formatWebsiteList(parsed.request.websites);
|
|
256
|
+
const durationLabel = parsed.request.durationMinutes === null
|
|
257
|
+
? "until you manually unblock"
|
|
258
|
+
: `for ${parsed.request.durationMinutes} minute${parsed.request.durationMinutes === 1 ? "" : "s"}`;
|
|
259
|
+
return {
|
|
260
|
+
success: true,
|
|
261
|
+
text: `Ready to block ${websitesLabel} ${durationLabel}. Reply "confirm" or re-issue with confirmed: true to start the block.`,
|
|
262
|
+
data: {
|
|
263
|
+
draft: true,
|
|
264
|
+
websites: parsed.request.websites,
|
|
265
|
+
durationMinutes: parsed.request.durationMinutes,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
237
269
|
const result = await startSelfControlBlock({
|
|
238
270
|
...parsed.request,
|
|
239
271
|
scheduledByAgentId: String(runtime.agentId),
|
|
@@ -299,6 +331,12 @@ export const blockWebsitesAction = {
|
|
|
299
331
|
required: false,
|
|
300
332
|
schema: { type: "number", default: 60 },
|
|
301
333
|
},
|
|
334
|
+
{
|
|
335
|
+
name: "confirmed",
|
|
336
|
+
description: "Set to true only when the owner has explicitly confirmed the block. Without it, the action returns a draft confirmation request instead of editing the system hosts file.",
|
|
337
|
+
required: false,
|
|
338
|
+
schema: { type: "boolean" },
|
|
339
|
+
},
|
|
302
340
|
],
|
|
303
341
|
examples: [
|
|
304
342
|
[
|
|
@@ -306,6 +344,17 @@ export const blockWebsitesAction = {
|
|
|
306
344
|
name: "{{name1}}",
|
|
307
345
|
content: { text: "Block x.com and twitter.com for 2 hours." },
|
|
308
346
|
},
|
|
347
|
+
{
|
|
348
|
+
name: "{{agentName}}",
|
|
349
|
+
content: {
|
|
350
|
+
text: "Ready to block x.com, twitter.com for 120 minutes. Reply \"confirm\" or re-issue with confirmed: true to start the block.",
|
|
351
|
+
action: "BLOCK_WEBSITES",
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "{{name1}}",
|
|
356
|
+
content: { text: "confirm" },
|
|
357
|
+
},
|
|
309
358
|
{
|
|
310
359
|
name: "{{agentName}}",
|
|
311
360
|
content: {
|