@elizaos/plugin-goals 2.0.3-beta.6 → 2.0.3-beta.7
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/actions/goals.d.ts +16 -0
- package/dist/actions/goals.d.ts.map +1 -0
- package/dist/actions/goals.js +150 -0
- package/dist/actions/goals.js.map +1 -0
- package/dist/components/goals/GoalsSpatialView.d.ts +42 -0
- package/dist/components/goals/GoalsSpatialView.d.ts.map +1 -0
- package/dist/components/goals/GoalsSpatialView.js +149 -0
- package/dist/components/goals/GoalsSpatialView.js.map +1 -0
- package/dist/components/goals/GoalsView.d.ts +60 -0
- package/dist/components/goals/GoalsView.d.ts.map +1 -0
- package/dist/components/goals/GoalsView.js +150 -0
- package/dist/components/goals/GoalsView.js.map +1 -0
- package/dist/components/goals/goals-view-bundle.d.ts +2 -0
- package/dist/components/goals/goals-view-bundle.d.ts.map +1 -0
- package/dist/components/goals/goals-view-bundle.js +5 -0
- package/dist/components/goals/goals-view-bundle.js.map +1 -0
- package/dist/db/goals-repository.d.ts +54 -0
- package/dist/db/goals-repository.d.ts.map +1 -0
- package/dist/db/goals-repository.js +239 -0
- package/dist/db/goals-repository.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +826 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +61 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/sql.d.ts +32 -0
- package/dist/db/sql.d.ts.map +1 -0
- package/dist/db/sql.js +130 -0
- package/dist/db/sql.js.map +1 -0
- package/dist/goal-grounding.d.ts +54 -0
- package/dist/goal-grounding.d.ts.map +1 -0
- package/dist/goal-grounding.js +148 -0
- package/dist/goal-grounding.js.map +1 -0
- package/dist/goal-normalize.d.ts +30 -0
- package/dist/goal-normalize.d.ts.map +1 -0
- package/dist/goal-normalize.js +99 -0
- package/dist/goal-normalize.js.map +1 -0
- package/dist/goal-semantic-evaluator.d.ts +12 -0
- package/dist/goal-semantic-evaluator.d.ts.map +1 -0
- package/dist/goal-semantic-evaluator.js +208 -0
- package/dist/goal-semantic-evaluator.js.map +1 -0
- package/dist/goals-runtime.d.ts +34 -0
- package/dist/goals-runtime.d.ts.map +1 -0
- package/dist/goals-runtime.js +44 -0
- package/dist/goals-runtime.js.map +1 -0
- package/dist/goals-service.d.ts +68 -0
- package/dist/goals-service.d.ts.map +1 -0
- package/dist/goals-service.js +293 -0
- package/dist/goals-service.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +13 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +47 -0
- package/dist/plugin.js.map +1 -0
- package/dist/register-terminal-view.d.ts +15 -0
- package/dist/register-terminal-view.d.ts.map +1 -0
- package/dist/register-terminal-view.js +25 -0
- package/dist/register-terminal-view.js.map +1 -0
- package/dist/register.d.ts +9 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +5 -0
- package/dist/register.js.map +1 -0
- package/dist/services/checkin.d.ts +23 -0
- package/dist/services/checkin.d.ts.map +1 -0
- package/dist/services/checkin.js +27 -0
- package/dist/services/checkin.js.map +1 -0
- package/dist/services/migration.d.ts +49 -0
- package/dist/services/migration.d.ts.map +1 -0
- package/dist/services/migration.js +113 -0
- package/dist/services/migration.js.map +1 -0
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +53 -0
- package/dist/types.js.map +1 -0
- package/dist/views/bundle.js +304 -0
- package/dist/views/bundle.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-destructive data migration for the goal tables carved out of
|
|
3
|
+
* @elizaos/plugin-personal-assistant.
|
|
4
|
+
*
|
|
5
|
+
* The two goal tables (`life_goal_definitions`, `life_goal_links`) used to live
|
|
6
|
+
* in the `app_lifeops` PostgreSQL schema, created by plugin-personal-assistant.
|
|
7
|
+
* They now live in `app_goals`, created by this plugin's drizzle schema.
|
|
8
|
+
* Existing installs still hold the owner's goal rows in `app_lifeops`, so on
|
|
9
|
+
* first boot we copy them across — once, idempotently, and WITHOUT ever touching
|
|
10
|
+
* the source.
|
|
11
|
+
*
|
|
12
|
+
* Guards (per table, independently):
|
|
13
|
+
* 1. Skip if the source table does not exist (fresh install / already dropped).
|
|
14
|
+
* 2. Skip if the target table is non-empty (migration already ran, or the
|
|
15
|
+
* plugin owns live data).
|
|
16
|
+
* 3. Otherwise copy every source row that is not already present in the target
|
|
17
|
+
* (a doubly-safe NOT EXISTS guard on the primary key).
|
|
18
|
+
*
|
|
19
|
+
* The source table is NEVER dropped or altered. The source and target share the
|
|
20
|
+
* exact column shape (PA's `app_lifeops` drizzle def and this plugin's
|
|
21
|
+
* `app_goals` def are column-identical), so the `SELECT s.*` copy is safe.
|
|
22
|
+
*
|
|
23
|
+
* Definitions are copied before links so a reader observing mid-copy never sees
|
|
24
|
+
* a link to a not-yet-copied definition.
|
|
25
|
+
*/
|
|
26
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
27
|
+
export declare const GOALS_MIGRATION_LOG_PREFIX = "[Goals]";
|
|
28
|
+
export declare const GOALS_MIGRATION_SERVICE_TYPE = "goals_migration";
|
|
29
|
+
export declare const MIGRATED_GOAL_TABLES: readonly ["life_goal_definitions", "life_goal_links"];
|
|
30
|
+
export type MigratedGoalTable = (typeof MIGRATED_GOAL_TABLES)[number];
|
|
31
|
+
export type SqlExecutor = (sql: string) => Promise<Array<Record<string, unknown>>>;
|
|
32
|
+
export interface TableMigrationResult {
|
|
33
|
+
table: MigratedGoalTable;
|
|
34
|
+
outcome: "copied" | "source-missing" | "target-non-empty";
|
|
35
|
+
}
|
|
36
|
+
export declare function migrateGoalTable(exec: SqlExecutor, table: MigratedGoalTable): Promise<TableMigrationResult>;
|
|
37
|
+
export declare function migrateGoalTables(exec: SqlExecutor): Promise<TableMigrationResult[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Service whose `start()` performs the one-time, guarded, non-destructive copy
|
|
40
|
+
* of the owner's goal rows from `app_lifeops` into `app_goals`.
|
|
41
|
+
*/
|
|
42
|
+
export declare class GoalsMigrationService extends Service {
|
|
43
|
+
static readonly serviceType = "goals_migration";
|
|
44
|
+
capabilityDescription: string;
|
|
45
|
+
static start(runtime: IAgentRuntime): Promise<GoalsMigrationService>;
|
|
46
|
+
private run;
|
|
47
|
+
stop(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/services/migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAU,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpE,eAAO,MAAM,0BAA0B,YAAY,CAAC;AACpD,eAAO,MAAM,4BAA4B,oBAAoB,CAAC;AAK9D,eAAO,MAAM,oBAAoB,uDAGvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,MAAM,KACR,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,QAAQ,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;CAC3D;AA0BD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAkB/B;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAOjC;AAmCD;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,OAAO;IAChD,gBAAyB,WAAW,qBAAgC;IAE3D,qBAAqB,SACoF;WAErG,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAM5D,GAAG;IAqBF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CACrC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { logger, Service } from "@elizaos/core";
|
|
2
|
+
const GOALS_MIGRATION_LOG_PREFIX = "[Goals]";
|
|
3
|
+
const GOALS_MIGRATION_SERVICE_TYPE = "goals_migration";
|
|
4
|
+
const SOURCE_SCHEMA = "app_lifeops";
|
|
5
|
+
const TARGET_SCHEMA = "app_goals";
|
|
6
|
+
const MIGRATED_GOAL_TABLES = [
|
|
7
|
+
"life_goal_definitions",
|
|
8
|
+
"life_goal_links"
|
|
9
|
+
];
|
|
10
|
+
function quoteIdent(name) {
|
|
11
|
+
return `"${name.replace(/"/g, '""')}"`;
|
|
12
|
+
}
|
|
13
|
+
async function sourceTableExists(exec, table) {
|
|
14
|
+
const rows = await exec(
|
|
15
|
+
`SELECT to_regclass('${SOURCE_SCHEMA}.${table}') IS NOT NULL AS present`
|
|
16
|
+
);
|
|
17
|
+
return rows[0]?.present === true || rows[0]?.present === "true";
|
|
18
|
+
}
|
|
19
|
+
async function targetTableIsEmpty(exec, table) {
|
|
20
|
+
const rows = await exec(
|
|
21
|
+
`SELECT NOT EXISTS (SELECT 1 FROM ${TARGET_SCHEMA}.${quoteIdent(table)}) AS empty`
|
|
22
|
+
);
|
|
23
|
+
return rows[0]?.empty === true || rows[0]?.empty === "true";
|
|
24
|
+
}
|
|
25
|
+
async function migrateGoalTable(exec, table) {
|
|
26
|
+
if (!await sourceTableExists(exec, table)) {
|
|
27
|
+
return { table, outcome: "source-missing" };
|
|
28
|
+
}
|
|
29
|
+
if (!await targetTableIsEmpty(exec, table)) {
|
|
30
|
+
return { table, outcome: "target-non-empty" };
|
|
31
|
+
}
|
|
32
|
+
const target = `${TARGET_SCHEMA}.${quoteIdent(table)}`;
|
|
33
|
+
const source = `${SOURCE_SCHEMA}.${quoteIdent(table)}`;
|
|
34
|
+
await exec(
|
|
35
|
+
`INSERT INTO ${target}
|
|
36
|
+
SELECT s.* FROM ${source} AS s
|
|
37
|
+
WHERE NOT EXISTS (
|
|
38
|
+
SELECT 1 FROM ${target} AS t WHERE t.id = s.id
|
|
39
|
+
)`
|
|
40
|
+
);
|
|
41
|
+
return { table, outcome: "copied" };
|
|
42
|
+
}
|
|
43
|
+
async function migrateGoalTables(exec) {
|
|
44
|
+
await exec(`CREATE SCHEMA IF NOT EXISTS ${TARGET_SCHEMA}`);
|
|
45
|
+
const results = [];
|
|
46
|
+
for (const table of MIGRATED_GOAL_TABLES) {
|
|
47
|
+
results.push(await migrateGoalTable(exec, table));
|
|
48
|
+
}
|
|
49
|
+
return results;
|
|
50
|
+
}
|
|
51
|
+
function getRuntimeDb(runtime) {
|
|
52
|
+
const db = runtime.db;
|
|
53
|
+
if (!db || typeof db.execute !== "function") {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`${GOALS_MIGRATION_LOG_PREFIX} runtime.db is unavailable \u2014 @elizaos/plugin-sql must be loaded before @elizaos/plugin-goals.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return db;
|
|
59
|
+
}
|
|
60
|
+
function extractRows(result) {
|
|
61
|
+
if (Array.isArray(result)) {
|
|
62
|
+
return result.filter(
|
|
63
|
+
(row) => typeof row === "object" && row !== null && !Array.isArray(row)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (result && typeof result === "object" && "rows" in result) {
|
|
67
|
+
const rows = result.rows;
|
|
68
|
+
if (Array.isArray(rows)) {
|
|
69
|
+
return rows.filter(
|
|
70
|
+
(row) => typeof row === "object" && row !== null && !Array.isArray(row)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
class GoalsMigrationService extends Service {
|
|
77
|
+
static serviceType = GOALS_MIGRATION_SERVICE_TYPE;
|
|
78
|
+
capabilityDescription = "Non-destructive one-time copy of goal rows from app_lifeops into app_goals during the plugin-goals carve-out.";
|
|
79
|
+
static async start(runtime) {
|
|
80
|
+
const service = new GoalsMigrationService(runtime);
|
|
81
|
+
await service.run();
|
|
82
|
+
return service;
|
|
83
|
+
}
|
|
84
|
+
async run() {
|
|
85
|
+
const db = getRuntimeDb(this.runtime);
|
|
86
|
+
const { sql } = await import("drizzle-orm");
|
|
87
|
+
const exec = async (statement) => extractRows(await db.execute(sql.raw(statement)));
|
|
88
|
+
const results = await migrateGoalTables(exec);
|
|
89
|
+
const copied = results.filter((r) => r.outcome === "copied");
|
|
90
|
+
if (copied.length > 0) {
|
|
91
|
+
logger.info(
|
|
92
|
+
{ tables: copied.map((r) => r.table) },
|
|
93
|
+
`${GOALS_MIGRATION_LOG_PREFIX} copied ${copied.length} goal table(s) from ${SOURCE_SCHEMA} to ${TARGET_SCHEMA}`
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
logger.debug(
|
|
97
|
+
{ results },
|
|
98
|
+
`${GOALS_MIGRATION_LOG_PREFIX} no goal tables required copying (already migrated or fresh install)`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async stop() {
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
GOALS_MIGRATION_LOG_PREFIX,
|
|
107
|
+
GOALS_MIGRATION_SERVICE_TYPE,
|
|
108
|
+
GoalsMigrationService,
|
|
109
|
+
MIGRATED_GOAL_TABLES,
|
|
110
|
+
migrateGoalTable,
|
|
111
|
+
migrateGoalTables
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/services/migration.ts"],"sourcesContent":["/**\n * Non-destructive data migration for the goal tables carved out of\n * @elizaos/plugin-personal-assistant.\n *\n * The two goal tables (`life_goal_definitions`, `life_goal_links`) used to live\n * in the `app_lifeops` PostgreSQL schema, created by plugin-personal-assistant.\n * They now live in `app_goals`, created by this plugin's drizzle schema.\n * Existing installs still hold the owner's goal rows in `app_lifeops`, so on\n * first boot we copy them across — once, idempotently, and WITHOUT ever touching\n * the source.\n *\n * Guards (per table, independently):\n * 1. Skip if the source table does not exist (fresh install / already dropped).\n * 2. Skip if the target table is non-empty (migration already ran, or the\n * plugin owns live data).\n * 3. Otherwise copy every source row that is not already present in the target\n * (a doubly-safe NOT EXISTS guard on the primary key).\n *\n * The source table is NEVER dropped or altered. The source and target share the\n * exact column shape (PA's `app_lifeops` drizzle def and this plugin's\n * `app_goals` def are column-identical), so the `SELECT s.*` copy is safe.\n *\n * Definitions are copied before links so a reader observing mid-copy never sees\n * a link to a not-yet-copied definition.\n */\n\nimport { type IAgentRuntime, logger, Service } from \"@elizaos/core\";\n\nexport const GOALS_MIGRATION_LOG_PREFIX = \"[Goals]\";\nexport const GOALS_MIGRATION_SERVICE_TYPE = \"goals_migration\";\n\nconst SOURCE_SCHEMA = \"app_lifeops\";\nconst TARGET_SCHEMA = \"app_goals\";\n\nexport const MIGRATED_GOAL_TABLES = [\n \"life_goal_definitions\",\n \"life_goal_links\",\n] as const;\n\nexport type MigratedGoalTable = (typeof MIGRATED_GOAL_TABLES)[number];\n\nexport type SqlExecutor = (\n sql: string,\n) => Promise<Array<Record<string, unknown>>>;\n\nexport interface TableMigrationResult {\n table: MigratedGoalTable;\n outcome: \"copied\" | \"source-missing\" | \"target-non-empty\";\n}\n\nfunction quoteIdent(name: string): string {\n return `\"${name.replace(/\"/g, '\"\"')}\"`;\n}\n\nasync function sourceTableExists(\n exec: SqlExecutor,\n table: MigratedGoalTable,\n): Promise<boolean> {\n const rows = await exec(\n `SELECT to_regclass('${SOURCE_SCHEMA}.${table}') IS NOT NULL AS present`,\n );\n return rows[0]?.present === true || rows[0]?.present === \"true\";\n}\n\nasync function targetTableIsEmpty(\n exec: SqlExecutor,\n table: MigratedGoalTable,\n): Promise<boolean> {\n const rows = await exec(\n `SELECT NOT EXISTS (SELECT 1 FROM ${TARGET_SCHEMA}.${quoteIdent(table)}) AS empty`,\n );\n return rows[0]?.empty === true || rows[0]?.empty === \"true\";\n}\n\nexport async function migrateGoalTable(\n exec: SqlExecutor,\n table: MigratedGoalTable,\n): Promise<TableMigrationResult> {\n if (!(await sourceTableExists(exec, table))) {\n return { table, outcome: \"source-missing\" };\n }\n if (!(await targetTableIsEmpty(exec, table))) {\n return { table, outcome: \"target-non-empty\" };\n }\n\n const target = `${TARGET_SCHEMA}.${quoteIdent(table)}`;\n const source = `${SOURCE_SCHEMA}.${quoteIdent(table)}`;\n await exec(\n `INSERT INTO ${target}\n SELECT s.* FROM ${source} AS s\n WHERE NOT EXISTS (\n SELECT 1 FROM ${target} AS t WHERE t.id = s.id\n )`,\n );\n return { table, outcome: \"copied\" };\n}\n\nexport async function migrateGoalTables(\n exec: SqlExecutor,\n): Promise<TableMigrationResult[]> {\n await exec(`CREATE SCHEMA IF NOT EXISTS ${TARGET_SCHEMA}`);\n const results: TableMigrationResult[] = [];\n for (const table of MIGRATED_GOAL_TABLES) {\n results.push(await migrateGoalTable(exec, table));\n }\n return results;\n}\n\ntype RuntimeDb = {\n execute: (query: unknown) => Promise<unknown>;\n};\n\nfunction getRuntimeDb(runtime: IAgentRuntime): RuntimeDb {\n const db = runtime.db as RuntimeDb | undefined;\n if (!db || typeof db.execute !== \"function\") {\n throw new Error(\n `${GOALS_MIGRATION_LOG_PREFIX} runtime.db is unavailable — @elizaos/plugin-sql must be loaded before @elizaos/plugin-goals.`,\n );\n }\n return db;\n}\n\nfunction extractRows(result: unknown): Array<Record<string, unknown>> {\n if (Array.isArray(result)) {\n return result.filter(\n (row): row is Record<string, unknown> =>\n typeof row === \"object\" && row !== null && !Array.isArray(row),\n );\n }\n if (result && typeof result === \"object\" && \"rows\" in result) {\n const rows = (result as { rows: unknown }).rows;\n if (Array.isArray(rows)) {\n return rows.filter(\n (row): row is Record<string, unknown> =>\n typeof row === \"object\" && row !== null && !Array.isArray(row),\n );\n }\n }\n return [];\n}\n\n/**\n * Service whose `start()` performs the one-time, guarded, non-destructive copy\n * of the owner's goal rows from `app_lifeops` into `app_goals`.\n */\nexport class GoalsMigrationService extends Service {\n static override readonly serviceType = GOALS_MIGRATION_SERVICE_TYPE;\n\n override capabilityDescription =\n \"Non-destructive one-time copy of goal rows from app_lifeops into app_goals during the plugin-goals carve-out.\";\n\n static async start(runtime: IAgentRuntime): Promise<GoalsMigrationService> {\n const service = new GoalsMigrationService(runtime);\n await service.run();\n return service;\n }\n\n private async run(): Promise<void> {\n const db = getRuntimeDb(this.runtime);\n const { sql } = await import(\"drizzle-orm\");\n const exec: SqlExecutor = async (statement) =>\n extractRows(await db.execute(sql.raw(statement)));\n\n const results = await migrateGoalTables(exec);\n const copied = results.filter((r) => r.outcome === \"copied\");\n if (copied.length > 0) {\n logger.info(\n { tables: copied.map((r) => r.table) },\n `${GOALS_MIGRATION_LOG_PREFIX} copied ${copied.length} goal table(s) from ${SOURCE_SCHEMA} to ${TARGET_SCHEMA}`,\n );\n } else {\n logger.debug(\n { results },\n `${GOALS_MIGRATION_LOG_PREFIX} no goal tables required copying (already migrated or fresh install)`,\n );\n }\n }\n\n override async stop(): Promise<void> {}\n}\n"],"mappings":"AA0BA,SAA6B,QAAQ,eAAe;AAE7C,MAAM,6BAA6B;AACnC,MAAM,+BAA+B;AAE5C,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AAEf,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AACF;AAaA,SAAS,WAAW,MAAsB;AACxC,SAAO,IAAI,KAAK,QAAQ,MAAM,IAAI,CAAC;AACrC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AA,IACF;AAAA,EACF;AAAA,EAEA,MAAe,OAAsB;AAAA,EAAC;AACxC;","names":[]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for @elizaos/plugin-goals.
|
|
3
|
+
*
|
|
4
|
+
* These mirror (and will eventually replace) the action contracts currently
|
|
5
|
+
* declared inside `plugins/plugin-personal-assistant/src/actions/owner-surfaces.ts`.
|
|
6
|
+
* During the decomposition phase the action handlers below remain stubs and
|
|
7
|
+
* delegate (via TODO comments) to the LifeOps implementations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GOALS_CONTEXTS: readonly ["goals", "self_care", "owner"];
|
|
10
|
+
export type GoalsContext = (typeof GOALS_CONTEXTS)[number];
|
|
11
|
+
export declare const GOAL_ACTIONS: readonly ["create", "update", "delete", "review"];
|
|
12
|
+
export type GoalActionName = (typeof GOAL_ACTIONS)[number];
|
|
13
|
+
export declare const ROUTINE_ACTIONS: readonly ["create", "update", "delete", "complete", "skip", "snooze", "review"];
|
|
14
|
+
export type RoutineActionName = (typeof ROUTINE_ACTIONS)[number];
|
|
15
|
+
export declare const REMINDER_ACTIONS: readonly ["create", "update", "delete", "complete", "snooze", "list"];
|
|
16
|
+
export type ReminderActionName = (typeof REMINDER_ACTIONS)[number];
|
|
17
|
+
export declare const ALARM_ACTIONS: readonly ["create", "update", "delete", "snooze", "dismiss", "list"];
|
|
18
|
+
export type AlarmActionName = (typeof ALARM_ACTIONS)[number];
|
|
19
|
+
export interface GoalsScope {
|
|
20
|
+
agentId: string;
|
|
21
|
+
entityId: string;
|
|
22
|
+
roomId?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const GOALS_CHECKIN_SERVICE_TYPE: "goals_checkin";
|
|
25
|
+
export declare const GOALS_LOG_PREFIX: "[plugin-goals]";
|
|
26
|
+
/** Lifecycle status of a goal (mirrors LIFEOPS_GOAL_STATUSES by value). */
|
|
27
|
+
export declare const GOAL_STATUSES: readonly ["active", "paused", "archived", "satisfied"];
|
|
28
|
+
export type GoalStatus = (typeof GOAL_STATUSES)[number];
|
|
29
|
+
/** Progress signal a goal review assigns (mirrors LIFEOPS_REVIEW_STATES). */
|
|
30
|
+
export declare const GOAL_REVIEW_STATES: readonly ["idle", "needs_attention", "on_track", "at_risk"];
|
|
31
|
+
export type GoalReviewState = (typeof GOAL_REVIEW_STATES)[number];
|
|
32
|
+
/** A goal flattened for display. Mapped from a `LifeOpsGoalRecord` at fetch. */
|
|
33
|
+
export interface GoalItem {
|
|
34
|
+
id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
/** Empty string when the goal carries no description. */
|
|
37
|
+
description: string;
|
|
38
|
+
status: GoalStatus;
|
|
39
|
+
reviewState: GoalReviewState;
|
|
40
|
+
/** Cadence kind (e.g. "daily" / "weekly"), or null when the goal is ad-hoc. */
|
|
41
|
+
cadenceKind: string | null;
|
|
42
|
+
/** Human-readable target / next-due from successCriteria, or null. */
|
|
43
|
+
target: string | null;
|
|
44
|
+
/** Count of linked occurrences / tasks / entities backing the goal. */
|
|
45
|
+
linkedCount: number;
|
|
46
|
+
/** ISO timestamp of the last update to the goal. */
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,cAAc,0CAA2C,CAAC;AACvE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,eAAO,MAAM,YAAY,mDAAoD,CAAC;AAC9E,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,eAAO,MAAM,eAAe,iFAQlB,CAAC;AACX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,e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|
+
const GOALS_CONTEXTS = ["goals", "self_care", "owner"];
|
|
2
|
+
const GOAL_ACTIONS = ["create", "update", "delete", "review"];
|
|
3
|
+
const ROUTINE_ACTIONS = [
|
|
4
|
+
"create",
|
|
5
|
+
"update",
|
|
6
|
+
"delete",
|
|
7
|
+
"complete",
|
|
8
|
+
"skip",
|
|
9
|
+
"snooze",
|
|
10
|
+
"review"
|
|
11
|
+
];
|
|
12
|
+
const REMINDER_ACTIONS = [
|
|
13
|
+
"create",
|
|
14
|
+
"update",
|
|
15
|
+
"delete",
|
|
16
|
+
"complete",
|
|
17
|
+
"snooze",
|
|
18
|
+
"list"
|
|
19
|
+
];
|
|
20
|
+
const ALARM_ACTIONS = [
|
|
21
|
+
"create",
|
|
22
|
+
"update",
|
|
23
|
+
"delete",
|
|
24
|
+
"snooze",
|
|
25
|
+
"dismiss",
|
|
26
|
+
"list"
|
|
27
|
+
];
|
|
28
|
+
const GOALS_CHECKIN_SERVICE_TYPE = "goals_checkin";
|
|
29
|
+
const GOALS_LOG_PREFIX = "[plugin-goals]";
|
|
30
|
+
const GOAL_STATUSES = [
|
|
31
|
+
"active",
|
|
32
|
+
"paused",
|
|
33
|
+
"archived",
|
|
34
|
+
"satisfied"
|
|
35
|
+
];
|
|
36
|
+
const GOAL_REVIEW_STATES = [
|
|
37
|
+
"idle",
|
|
38
|
+
"needs_attention",
|
|
39
|
+
"on_track",
|
|
40
|
+
"at_risk"
|
|
41
|
+
];
|
|
42
|
+
export {
|
|
43
|
+
ALARM_ACTIONS,
|
|
44
|
+
GOALS_CHECKIN_SERVICE_TYPE,
|
|
45
|
+
GOALS_CONTEXTS,
|
|
46
|
+
GOALS_LOG_PREFIX,
|
|
47
|
+
GOAL_ACTIONS,
|
|
48
|
+
GOAL_REVIEW_STATES,
|
|
49
|
+
GOAL_STATUSES,
|
|
50
|
+
REMINDER_ACTIONS,
|
|
51
|
+
ROUTINE_ACTIONS
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * Public types for @elizaos/plugin-goals.\n *\n * These mirror (and will eventually replace) the action contracts currently\n * declared inside `plugins/plugin-personal-assistant/src/actions/owner-surfaces.ts`.\n * During the decomposition phase the action handlers below remain stubs and\n * delegate (via TODO comments) to the LifeOps implementations.\n */\n\nexport const GOALS_CONTEXTS = [\"goals\", \"self_care\", \"owner\"] as const;\nexport type GoalsContext = (typeof GOALS_CONTEXTS)[number];\n\nexport const GOAL_ACTIONS = [\"create\", \"update\", \"delete\", \"review\"] as const;\nexport type GoalActionName = (typeof GOAL_ACTIONS)[number];\n\nexport const ROUTINE_ACTIONS = [\n \"create\",\n \"update\",\n \"delete\",\n \"complete\",\n \"skip\",\n \"snooze\",\n \"review\",\n] as const;\nexport type RoutineActionName = (typeof ROUTINE_ACTIONS)[number];\n\nexport const REMINDER_ACTIONS = [\n \"create\",\n \"update\",\n \"delete\",\n \"complete\",\n \"snooze\",\n \"list\",\n] as const;\nexport type ReminderActionName = (typeof REMINDER_ACTIONS)[number];\n\nexport const ALARM_ACTIONS = [\n \"create\",\n \"update\",\n \"delete\",\n \"snooze\",\n \"dismiss\",\n \"list\",\n] as const;\nexport type AlarmActionName = (typeof ALARM_ACTIONS)[number];\n\nexport interface GoalsScope {\n agentId: string;\n entityId: string;\n roomId?: string;\n}\n\nexport const GOALS_CHECKIN_SERVICE_TYPE = \"goals_checkin\" as const;\nexport const GOALS_LOG_PREFIX = \"[plugin-goals]\" as const;\n\n// ---------------------------------------------------------------------------\n// View display DTOs.\n//\n// `GoalsView` reads `GET {base}/api/lifeops/goals`, which returns\n// `{ goals: LifeOpsGoalRecord[] }` where each record is\n// `{ goal: LifeOpsGoalDefinition; links: LifeOpsGoalLink[] }`\n// (see LifeOpsGoalDefinition / LifeOpsGoalLink in\n// packages/shared/src/contracts/personal-assistant.ts, served by the\n// `/api/lifeops/goals` branch of\n// plugins/plugin-personal-assistant/src/routes/lifeops-routes.ts).\n//\n// These display DTOs are the flat shape the view renders after mapping each\n// wire record at the fetch boundary. The wire DTOs themselves are declared\n// locally inside GoalsView.tsx; this plugin MUST NOT import the PA contract\n// types. The status / review-state literals below mirror the real enums\n// (LIFEOPS_GOAL_STATUSES / LIFEOPS_REVIEW_STATES) by value.\n// ---------------------------------------------------------------------------\n\n/** Lifecycle status of a goal (mirrors LIFEOPS_GOAL_STATUSES by value). */\nexport const GOAL_STATUSES = [\n \"active\",\n \"paused\",\n \"archived\",\n \"satisfied\",\n] as const;\nexport type GoalStatus = (typeof GOAL_STATUSES)[number];\n\n/** Progress signal a goal review assigns (mirrors LIFEOPS_REVIEW_STATES). */\nexport const GOAL_REVIEW_STATES = [\n \"idle\",\n \"needs_attention\",\n \"on_track\",\n \"at_risk\",\n] as const;\nexport type GoalReviewState = (typeof GOAL_REVIEW_STATES)[number];\n\n/** A goal flattened for display. Mapped from a `LifeOpsGoalRecord` at fetch. */\nexport interface GoalItem {\n id: string;\n title: string;\n /** Empty string when the goal carries no description. */\n description: string;\n status: GoalStatus;\n reviewState: GoalReviewState;\n /** Cadence kind (e.g. \"daily\" / \"weekly\"), or null when the goal is ad-hoc. */\n cadenceKind: string | null;\n /** Human-readable target / next-due from successCriteria, or null. */\n target: string | null;\n /** Count of linked occurrences / tasks / entities backing the goal. */\n linkedCount: number;\n /** ISO timestamp of the last update to the goal. */\n updatedAt: string;\n}\n"],"mappings":"AASO,MAAM,iBAAiB,CAAC,SAAS,aAAa,OAAO;AAGrD,MAAM,eAAe,CAAC,UAAU,UAAU,UAAU,QAAQ;AAG5D,MAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,MAAM,6BAA6B;AACnC,MAAM,mBAAmB;AAqBzB,MAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { client as e } from "@elizaos/ui";
|
|
2
|
+
import { Button as t, Card as n, HStack as r, List as i, SpatialSurface as a, Text as o, VStack as s } from "@elizaos/ui/spatial";
|
|
3
|
+
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
4
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
5
|
+
//#region src/types.ts
|
|
6
|
+
var g = [
|
|
7
|
+
"active",
|
|
8
|
+
"paused",
|
|
9
|
+
"archived",
|
|
10
|
+
"satisfied"
|
|
11
|
+
], _ = {
|
|
12
|
+
active: "Active",
|
|
13
|
+
paused: "Paused",
|
|
14
|
+
archived: "Archived",
|
|
15
|
+
satisfied: "Achieved"
|
|
16
|
+
}, v = {
|
|
17
|
+
idle: "not reviewed",
|
|
18
|
+
on_track: "on track",
|
|
19
|
+
at_risk: "at risk",
|
|
20
|
+
needs_attention: "needs attention"
|
|
21
|
+
}, y = {
|
|
22
|
+
idle: "○",
|
|
23
|
+
on_track: "●",
|
|
24
|
+
at_risk: "x",
|
|
25
|
+
needs_attention: "x"
|
|
26
|
+
}, b = {
|
|
27
|
+
idle: "muted",
|
|
28
|
+
on_track: "success",
|
|
29
|
+
at_risk: "danger",
|
|
30
|
+
needs_attention: "danger"
|
|
31
|
+
};
|
|
32
|
+
function x(e) {
|
|
33
|
+
let t = new Date(e);
|
|
34
|
+
return Number.isNaN(t.getTime()) ? e : t.toLocaleDateString(void 0, {
|
|
35
|
+
month: "short",
|
|
36
|
+
day: "numeric",
|
|
37
|
+
year: "numeric"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function S(e) {
|
|
41
|
+
let t = e.filter((e) => e.reviewState === "at_risk" || e.reviewState === "needs_attention").length;
|
|
42
|
+
return t === 0 ? null : t === 1 ? "1 goal needs a review." : `${t} goals need a review.`;
|
|
43
|
+
}
|
|
44
|
+
function C({ snapshot: e, onAction: t }) {
|
|
45
|
+
let r = (e) => () => t?.(e), i = new Set(e.activeStatuses);
|
|
46
|
+
return /* @__PURE__ */ m(n, {
|
|
47
|
+
gap: 1,
|
|
48
|
+
padding: 1,
|
|
49
|
+
children: e.status === "loading" ? /* @__PURE__ */ m(o, {
|
|
50
|
+
tone: "muted",
|
|
51
|
+
style: "caption",
|
|
52
|
+
children: "Loading goals"
|
|
53
|
+
}) : e.status === "error" ? /* @__PURE__ */ m(w, {
|
|
54
|
+
error: e.error,
|
|
55
|
+
dispatch: r
|
|
56
|
+
}) : /* @__PURE__ */ m(T, {
|
|
57
|
+
snapshot: e,
|
|
58
|
+
active: i,
|
|
59
|
+
dispatch: r
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function w({ error: e, dispatch: n }) {
|
|
64
|
+
return /* @__PURE__ */ h(p, { children: [
|
|
65
|
+
/* @__PURE__ */ m(o, {
|
|
66
|
+
bold: !0,
|
|
67
|
+
children: "Could not load goals"
|
|
68
|
+
}),
|
|
69
|
+
e ? /* @__PURE__ */ m(o, {
|
|
70
|
+
tone: "muted",
|
|
71
|
+
style: "caption",
|
|
72
|
+
children: e
|
|
73
|
+
}) : null,
|
|
74
|
+
/* @__PURE__ */ m(r, {
|
|
75
|
+
gap: 1,
|
|
76
|
+
children: /* @__PURE__ */ m(t, {
|
|
77
|
+
agent: "retry",
|
|
78
|
+
onPress: n("retry"),
|
|
79
|
+
children: "Retry"
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
function T({ snapshot: e, active: n, dispatch: i }) {
|
|
85
|
+
let a = S(e.goals);
|
|
86
|
+
if (e.goals.length === 0) return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(o, {
|
|
87
|
+
bold: !0,
|
|
88
|
+
children: "None"
|
|
89
|
+
}), /* @__PURE__ */ m(r, {
|
|
90
|
+
gap: 1,
|
|
91
|
+
children: /* @__PURE__ */ m(t, {
|
|
92
|
+
agent: "new",
|
|
93
|
+
onPress: i("new"),
|
|
94
|
+
children: "Set a goal"
|
|
95
|
+
})
|
|
96
|
+
})] });
|
|
97
|
+
let s = g.map((t) => ({
|
|
98
|
+
status: t,
|
|
99
|
+
goals: e.goals.filter((e) => e.status === t)
|
|
100
|
+
})).filter((e) => e.goals.length === 0 ? !1 : n.size === 0 ? !0 : n.has(e.status));
|
|
101
|
+
return /* @__PURE__ */ h(p, { children: [
|
|
102
|
+
a ? /* @__PURE__ */ m(o, {
|
|
103
|
+
tone: "muted",
|
|
104
|
+
style: "caption",
|
|
105
|
+
children: a
|
|
106
|
+
}) : null,
|
|
107
|
+
/* @__PURE__ */ m(r, {
|
|
108
|
+
gap: 1,
|
|
109
|
+
wrap: !0,
|
|
110
|
+
children: g.map((e) => /* @__PURE__ */ m(t, {
|
|
111
|
+
variant: n.has(e) ? "solid" : "outline",
|
|
112
|
+
tone: n.has(e) ? "primary" : "default",
|
|
113
|
+
agent: `filter:${e}`,
|
|
114
|
+
onPress: i(`filter:${e}`),
|
|
115
|
+
children: _[e]
|
|
116
|
+
}, e))
|
|
117
|
+
}),
|
|
118
|
+
s.length === 0 ? /* @__PURE__ */ m(o, {
|
|
119
|
+
tone: "muted",
|
|
120
|
+
align: "center",
|
|
121
|
+
style: "caption",
|
|
122
|
+
children: "None"
|
|
123
|
+
}) : s.map((e) => /* @__PURE__ */ m(E, { group: e }, e.status))
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
126
|
+
function E({ group: e }) {
|
|
127
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ h(o, {
|
|
128
|
+
style: "caption",
|
|
129
|
+
tone: "muted",
|
|
130
|
+
children: [
|
|
131
|
+
_[e.status],
|
|
132
|
+
" (",
|
|
133
|
+
e.goals.length,
|
|
134
|
+
")"
|
|
135
|
+
]
|
|
136
|
+
}), /* @__PURE__ */ m(i, {
|
|
137
|
+
gap: 0,
|
|
138
|
+
children: e.goals.map((e) => /* @__PURE__ */ m(D, { goal: e }, e.id))
|
|
139
|
+
})] });
|
|
140
|
+
}
|
|
141
|
+
function D({ goal: e }) {
|
|
142
|
+
let t = [];
|
|
143
|
+
return e.cadenceKind && t.push(e.cadenceKind), e.target && t.push(e.target), e.linkedCount > 0 && t.push(`${e.linkedCount} linked`), /* @__PURE__ */ h(r, {
|
|
144
|
+
gap: 1,
|
|
145
|
+
align: "center",
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ m(o, {
|
|
148
|
+
tone: b[e.reviewState],
|
|
149
|
+
wrap: !1,
|
|
150
|
+
children: y[e.reviewState]
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ h(s, {
|
|
153
|
+
gap: 0,
|
|
154
|
+
grow: 1,
|
|
155
|
+
children: [/* @__PURE__ */ m(o, {
|
|
156
|
+
bold: !0,
|
|
157
|
+
wrap: !1,
|
|
158
|
+
children: e.title
|
|
159
|
+
}), t.length > 0 ? /* @__PURE__ */ m(o, {
|
|
160
|
+
style: "caption",
|
|
161
|
+
tone: "muted",
|
|
162
|
+
wrap: !1,
|
|
163
|
+
children: t.join(" · ")
|
|
164
|
+
}) : null]
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ h(s, {
|
|
167
|
+
gap: 0,
|
|
168
|
+
children: [/* @__PURE__ */ m(o, {
|
|
169
|
+
style: "caption",
|
|
170
|
+
tone: b[e.reviewState],
|
|
171
|
+
wrap: !1,
|
|
172
|
+
align: "end",
|
|
173
|
+
children: v[e.reviewState]
|
|
174
|
+
}), /* @__PURE__ */ m(o, {
|
|
175
|
+
style: "caption",
|
|
176
|
+
tone: "muted",
|
|
177
|
+
wrap: !1,
|
|
178
|
+
align: "end",
|
|
179
|
+
children: x(e.updatedAt)
|
|
180
|
+
})]
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/components/goals/GoalsView.tsx
|
|
187
|
+
async function O() {
|
|
188
|
+
let t = await fetch(`${e.getBaseUrl()}/api/lifeops/goals`);
|
|
189
|
+
if (!t.ok) throw Error(`Goals request failed (${t.status})`);
|
|
190
|
+
return await t.json();
|
|
191
|
+
}
|
|
192
|
+
var k = { fetchGoals: O }, A = new Set(g), j = new Set([
|
|
193
|
+
"idle",
|
|
194
|
+
"needs_attention",
|
|
195
|
+
"on_track",
|
|
196
|
+
"at_risk"
|
|
197
|
+
]);
|
|
198
|
+
function M(e) {
|
|
199
|
+
return A.has(e) ? e : "active";
|
|
200
|
+
}
|
|
201
|
+
function N(e) {
|
|
202
|
+
return j.has(e) ? e : "idle";
|
|
203
|
+
}
|
|
204
|
+
function P(e) {
|
|
205
|
+
return e && typeof e.kind == "string" && e.kind.length > 0 ? e.kind : null;
|
|
206
|
+
}
|
|
207
|
+
function F(e) {
|
|
208
|
+
let t = e.targetText ?? e.target ?? e.summary ?? e.deadline ?? e.dueAt;
|
|
209
|
+
return typeof t == "string" && t.length > 0 ? t : typeof t == "number" ? String(t) : null;
|
|
210
|
+
}
|
|
211
|
+
function I(e) {
|
|
212
|
+
let { goal: t, links: n } = e;
|
|
213
|
+
return {
|
|
214
|
+
id: t.id,
|
|
215
|
+
title: t.title,
|
|
216
|
+
description: t.description ?? "",
|
|
217
|
+
status: M(t.status),
|
|
218
|
+
reviewState: N(t.reviewState),
|
|
219
|
+
cadenceKind: P(t.cadence),
|
|
220
|
+
target: F(t.successCriteria ?? {}),
|
|
221
|
+
linkedCount: n.length,
|
|
222
|
+
updatedAt: t.updatedAt
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function L() {
|
|
226
|
+
e.sendChatMessage?.("Help me set a goal to head toward this quarter.");
|
|
227
|
+
}
|
|
228
|
+
function R(e = {}) {
|
|
229
|
+
let t = e.fetchers ?? k, [n, r] = f({ kind: "loading" }), [i, o] = f(() => /* @__PURE__ */ new Set()), s = d(t);
|
|
230
|
+
s.current = t;
|
|
231
|
+
let p = c(() => {
|
|
232
|
+
let e = !1;
|
|
233
|
+
return r({ kind: "loading" }), s.current.fetchGoals().then((t) => {
|
|
234
|
+
e || r({
|
|
235
|
+
kind: "ready",
|
|
236
|
+
goals: t.goals.map(I)
|
|
237
|
+
});
|
|
238
|
+
}).catch((t) => {
|
|
239
|
+
e || r({
|
|
240
|
+
kind: "error",
|
|
241
|
+
message: t instanceof Error ? t.message : "Could not load goals."
|
|
242
|
+
});
|
|
243
|
+
}), () => {
|
|
244
|
+
e = !0;
|
|
245
|
+
};
|
|
246
|
+
}, []);
|
|
247
|
+
l(() => {
|
|
248
|
+
let e = p(), t = !0, n = setInterval(() => {
|
|
249
|
+
s.current.fetchGoals().then((e) => {
|
|
250
|
+
t && r({
|
|
251
|
+
kind: "ready",
|
|
252
|
+
goals: e.goals.map(I)
|
|
253
|
+
});
|
|
254
|
+
}).catch(() => {});
|
|
255
|
+
}, 2e4);
|
|
256
|
+
return () => {
|
|
257
|
+
t = !1, clearInterval(n), e();
|
|
258
|
+
};
|
|
259
|
+
}, [p]);
|
|
260
|
+
let h = c((e) => {
|
|
261
|
+
o((t) => {
|
|
262
|
+
let n = new Set(t);
|
|
263
|
+
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
264
|
+
});
|
|
265
|
+
}, []), g = c((e) => {
|
|
266
|
+
if (e.startsWith("filter:")) {
|
|
267
|
+
let t = e.slice(7);
|
|
268
|
+
A.has(t) && h(t);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
switch (e) {
|
|
272
|
+
case "retry":
|
|
273
|
+
p();
|
|
274
|
+
return;
|
|
275
|
+
case "new":
|
|
276
|
+
L();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
}, [p, h]);
|
|
280
|
+
return /* @__PURE__ */ m(a, { children: /* @__PURE__ */ m(C, {
|
|
281
|
+
snapshot: u(() => {
|
|
282
|
+
let e = Array.from(i);
|
|
283
|
+
return n.kind === "loading" ? {
|
|
284
|
+
status: "loading",
|
|
285
|
+
goals: [],
|
|
286
|
+
activeStatuses: e
|
|
287
|
+
} : n.kind === "error" ? {
|
|
288
|
+
status: "error",
|
|
289
|
+
goals: [],
|
|
290
|
+
activeStatuses: e,
|
|
291
|
+
error: n.message
|
|
292
|
+
} : {
|
|
293
|
+
status: "ready",
|
|
294
|
+
goals: n.goals,
|
|
295
|
+
activeStatuses: e
|
|
296
|
+
};
|
|
297
|
+
}, [n, i]),
|
|
298
|
+
onAction: g
|
|
299
|
+
}) });
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
export { R as GoalsView };
|
|
303
|
+
|
|
304
|
+
//# sourceMappingURL=bundle.js.map
|