agent-sin 0.1.11 → 0.1.15

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +2 -1
  3. package/builtin-skills/_shared/_todo_lib.py +290 -0
  4. package/builtin-skills/even-g2-setup/main.ts +896 -0
  5. package/builtin-skills/even-g2-setup/skill.yaml +133 -0
  6. package/builtin-skills/memo-delete/main.py +28 -107
  7. package/builtin-skills/memo-delete/skill.yaml +10 -21
  8. package/builtin-skills/memo-index/main.py +96 -64
  9. package/builtin-skills/memo-index/skill.yaml +4 -10
  10. package/builtin-skills/memo-list/main.py +179 -0
  11. package/builtin-skills/memo-list/skill.yaml +51 -0
  12. package/builtin-skills/memo-save/main.py +191 -25
  13. package/builtin-skills/memo-save/skill.yaml +29 -5
  14. package/builtin-skills/memo-search/main.py +38 -18
  15. package/builtin-skills/memo-vector-search/main.py +11 -6
  16. package/builtin-skills/nightly-topic-knowledge/_feedback_lib.py +391 -0
  17. package/builtin-skills/nightly-topic-knowledge/_topics_lib.py +415 -0
  18. package/builtin-skills/nightly-topic-knowledge/main.py +403 -0
  19. package/builtin-skills/nightly-topic-knowledge/skill.yaml +88 -0
  20. package/builtin-skills/schedule-add/main.py +26 -0
  21. package/builtin-skills/service-restart/main.ts +249 -0
  22. package/builtin-skills/service-restart/skill.yaml +49 -0
  23. package/builtin-skills/todo-add/main.py +3 -1
  24. package/builtin-skills/todo-delete/main.py +3 -1
  25. package/builtin-skills/todo-done/main.py +3 -1
  26. package/builtin-skills/todo-list/main.py +4 -1
  27. package/builtin-skills/todo-tick/main.py +3 -1
  28. package/builtin-skills/topic-knowledge-read/main.py +118 -0
  29. package/builtin-skills/topic-knowledge-read/skill.yaml +49 -0
  30. package/dist/builder/build-action-classifier.d.ts +18 -0
  31. package/dist/builder/build-action-classifier.js +82 -1
  32. package/dist/builder/build-flow.d.ts +33 -4
  33. package/dist/builder/build-flow.js +251 -89
  34. package/dist/builder/builder-session.d.ts +1 -1
  35. package/dist/builder/builder-session.js +112 -7
  36. package/dist/builder/conversation-router.d.ts +4 -2
  37. package/dist/builder/conversation-router.js +19 -2
  38. package/dist/cli/index.js +323 -20
  39. package/dist/core/ai-provider.d.ts +1 -0
  40. package/dist/core/ai-provider.js +8 -3
  41. package/dist/core/chat-engine.d.ts +10 -3
  42. package/dist/core/chat-engine.js +1563 -197
  43. package/dist/core/config.d.ts +4 -0
  44. package/dist/core/config.js +82 -0
  45. package/dist/core/daily-memory-promotion.d.ts +7 -0
  46. package/dist/core/daily-memory-promotion.js +568 -14
  47. package/dist/core/image-attachments.d.ts +31 -0
  48. package/dist/core/image-attachments.js +237 -0
  49. package/dist/core/logger.d.ts +2 -1
  50. package/dist/core/logger.js +77 -1
  51. package/dist/core/memo-migration.d.ts +3 -0
  52. package/dist/core/memo-migration.js +422 -0
  53. package/dist/core/native-modules.d.ts +24 -0
  54. package/dist/core/native-modules.js +99 -0
  55. package/dist/core/notifier.d.ts +8 -3
  56. package/dist/core/notifier.js +191 -17
  57. package/dist/core/obsidian-vault.d.ts +19 -0
  58. package/dist/core/obsidian-vault.js +477 -0
  59. package/dist/core/operating-model.d.ts +2 -0
  60. package/dist/core/operating-model.js +15 -0
  61. package/dist/core/output-writer.d.ts +3 -2
  62. package/dist/core/output-writer.js +108 -7
  63. package/dist/core/profile-memory.js +22 -1
  64. package/dist/core/runtime.d.ts +2 -0
  65. package/dist/core/runtime.js +9 -1
  66. package/dist/core/secrets.d.ts +4 -0
  67. package/dist/core/secrets.js +34 -0
  68. package/dist/core/skill-history.d.ts +44 -0
  69. package/dist/core/skill-history.js +329 -0
  70. package/dist/core/skill-registry.d.ts +5 -0
  71. package/dist/core/skill-registry.js +11 -0
  72. package/dist/discord/bot.d.ts +13 -0
  73. package/dist/discord/bot.js +542 -10
  74. package/dist/even-g2/gateway.d.ts +15 -0
  75. package/dist/even-g2/gateway.js +868 -0
  76. package/dist/runtimes/codex-app-server.d.ts +5 -1
  77. package/dist/runtimes/codex-app-server.js +147 -8
  78. package/dist/runtimes/python-runner.js +82 -0
  79. package/dist/runtimes/typescript-runner.js +13 -1
  80. package/dist/skills-sdk/types.d.ts +19 -4
  81. package/dist/telegram/bot.d.ts +1 -0
  82. package/dist/telegram/bot.js +122 -31
  83. package/package.json +3 -1
  84. package/templates/even-g2-agent/README.md +83 -0
  85. package/templates/even-g2-agent/app.json +20 -0
  86. package/templates/even-g2-agent/index.html +31 -0
  87. package/templates/even-g2-agent/package-lock.json +1836 -0
  88. package/templates/even-g2-agent/package.json +22 -0
  89. package/templates/even-g2-agent/scripts/qr-auto.mjs +182 -0
  90. package/templates/even-g2-agent/src/embedded-config.ts +4 -0
  91. package/templates/even-g2-agent/src/main.ts +539 -0
  92. package/templates/even-g2-agent/src/style.css +70 -0
  93. package/templates/even-g2-agent/tsconfig.json +11 -0
  94. package/templates/skill-python/main.py +20 -2
  95. package/templates/skill-python/skill.yaml +9 -0
  96. package/templates/skill-typescript/main.ts +40 -5
  97. package/templates/skill-typescript/skill.yaml +9 -0
@@ -8,6 +8,8 @@ export interface AppConfig {
8
8
  memory_dir: string;
9
9
  index_dir: string;
10
10
  logs_dir: string;
11
+ skill_outputs_dir: string;
12
+ obsidian_vault_dir?: string;
11
13
  log_retention_days: number;
12
14
  event_log_retention_days: number;
13
15
  defaults: {
@@ -39,6 +41,7 @@ export interface SetupWorkspaceOptions {
39
41
  memoryDir?: string;
40
42
  indexDir?: string;
41
43
  logsDir?: string;
44
+ skillOutputsDir?: string;
42
45
  chatModel?: string;
43
46
  builder?: string;
44
47
  enableModels?: string[];
@@ -92,6 +95,7 @@ export declare function deriveSetupChoicePairIds(chat: SetupModelChoice, builder
92
95
  };
93
96
  export declare function setupWorkspace(options?: SetupWorkspaceOptions): Promise<AppConfig>;
94
97
  export declare function ensureDailyMemoIndexSchedule(config: AppConfig): Promise<void>;
98
+ export declare function ensureNightlyTopicKnowledgeSchedule(config: AppConfig): Promise<void>;
95
99
  export declare function ensureWorkspaceDirs(config: AppConfig): Promise<void>;
96
100
  export declare function loadConfig(): Promise<AppConfig>;
97
101
  export declare function loadModels(workspace?: string): Promise<ModelConfig>;
@@ -7,6 +7,7 @@ import { fileURLToPath } from "node:url";
7
7
  import YAML from "yaml";
8
8
  import { ensureDotenvSkeleton } from "./secrets.js";
9
9
  import { ensureProfileMemoryFiles } from "./profile-memory.js";
10
+ import { defaultObsidianVaultDir, ensureObsidianVault } from "./obsidian-vault.js";
10
11
  import { migrateLegacyBuiltinCopies } from "./builtin-skills.js";
11
12
  import { l, setLocale } from "./i18n.js";
12
13
  let cachedInstallRoot = null;
@@ -127,6 +128,8 @@ export function defaultConfig(workspace = defaultWorkspace()) {
127
128
  memory_dir: path.join(workspace, "memory"),
128
129
  index_dir: path.join(workspace, "index"),
129
130
  logs_dir: path.join(workspace, "logs"),
131
+ skill_outputs_dir: path.join(workspace, "skill-outputs"),
132
+ obsidian_vault_dir: defaultObsidianVaultDir(),
130
133
  log_retention_days: 14,
131
134
  event_log_retention_days: 90,
132
135
  defaults: {
@@ -687,9 +690,23 @@ export async function setupWorkspace(options = {}) {
687
690
  await migrateLegacySchedules(config.workspace);
688
691
  await ensureSchedulesSkeleton(schedulesPath(config.workspace));
689
692
  await ensureDailyMemoIndexSchedule(config);
693
+ await ensureNightlyTopicKnowledgeSchedule(config);
690
694
  await migrateLegacyBuiltinCopies(config.skills_dir);
691
695
  await ensureProfileMemoryFiles(config);
692
696
  await ensureDotenvSkeleton(config.workspace);
697
+ try {
698
+ const { migrateMemoFlatStructure } = await import("./memo-migration.js");
699
+ await migrateMemoFlatStructure(config);
700
+ }
701
+ catch (error) {
702
+ console.warn(`memo-migration: skipped: ${error.message}`);
703
+ }
704
+ try {
705
+ await ensureObsidianVault(config);
706
+ }
707
+ catch {
708
+ // Obsidian Vault のセットアップ失敗は致命傷にしない(Windows の symlink 権限など)
709
+ }
693
710
  return config;
694
711
  }
695
712
  // models.yaml の roles から実体モデル ID を取り出す。未設定 / 不正の場合は fallback を返す。
@@ -791,6 +808,51 @@ export async function ensureDailyMemoIndexSchedule(config) {
791
808
  await writeFile(file, YAML.stringify({ ...parsed, schedules }), "utf8");
792
809
  await writeFile(marker, "", "utf8");
793
810
  }
811
+ const NIGHTLY_TOPIC_KNOWLEDGE_ID = "nightly-topic-knowledge";
812
+ function nightlyTopicKnowledgeMarkerPath(workspace) {
813
+ return path.join(workspace, ".nightly-topic-knowledge-installed");
814
+ }
815
+ // Auto-register the nightly topic-knowledge cron on first run / upgrade.
816
+ // Idempotent: the marker file ensures we only add it once, so a user who
817
+ // deletes the schedule keeps it deleted on subsequent commands.
818
+ export async function ensureNightlyTopicKnowledgeSchedule(config) {
819
+ const marker = nightlyTopicKnowledgeMarkerPath(config.workspace);
820
+ try {
821
+ await stat(marker);
822
+ return;
823
+ }
824
+ catch {
825
+ // No marker — proceed.
826
+ }
827
+ const file = schedulesPath(config.workspace);
828
+ let raw;
829
+ try {
830
+ raw = await readFile(file, "utf8");
831
+ }
832
+ catch {
833
+ return;
834
+ }
835
+ let parsed;
836
+ try {
837
+ parsed = YAML.parse(raw) ?? {};
838
+ }
839
+ catch {
840
+ return;
841
+ }
842
+ const schedules = Array.isArray(parsed.schedules) ? [...parsed.schedules] : [];
843
+ const alreadyRegistered = schedules.some((entry) => entry && typeof entry === "object" && entry.id === NIGHTLY_TOPIC_KNOWLEDGE_ID);
844
+ if (!alreadyRegistered) {
845
+ schedules.push({
846
+ id: NIGHTLY_TOPIC_KNOWLEDGE_ID,
847
+ description: l("Distill yesterday's conversations and notes into per-topic knowledge.", "前日の会話とメモをトピック別ナレッジに整理する"),
848
+ cron: "10 0 * * *",
849
+ skill: NIGHTLY_TOPIC_KNOWLEDGE_ID,
850
+ enabled: true,
851
+ });
852
+ await writeFile(file, YAML.stringify({ ...parsed, schedules }), "utf8");
853
+ }
854
+ await writeFile(marker, "", "utf8");
855
+ }
794
856
  async function detectMemoIndexDependencies(workspace) {
795
857
  const venvPython = path.join(workspace, ".venv", "bin", "python");
796
858
  const candidates = [];
@@ -850,6 +912,7 @@ export async function ensureWorkspaceDirs(config) {
850
912
  await mkdir(path.join(config.index_dir, "local-index"), { recursive: true });
851
913
  await mkdir(config.logs_dir, { recursive: true });
852
914
  await mkdir(path.join(config.logs_dir, "runs"), { recursive: true });
915
+ await mkdir(config.skill_outputs_dir, { recursive: true });
853
916
  }
854
917
  export async function loadConfig() {
855
918
  const file = configPath();
@@ -1171,6 +1234,8 @@ export function normalizeConfig(config) {
1171
1234
  memory_dir: expandHome(config.memory_dir || path.join(workspace, "memory")),
1172
1235
  index_dir: expandHome(config.index_dir || path.join(workspace, "index")),
1173
1236
  logs_dir: expandHome(config.logs_dir || path.join(workspace, "logs")),
1237
+ skill_outputs_dir: expandHome(config.skill_outputs_dir || path.join(workspace, "skill-outputs")),
1238
+ obsidian_vault_dir: normalizeObsidianVaultDir(config.obsidian_vault_dir),
1174
1239
  log_retention_days: typeof config.log_retention_days === "number" && config.log_retention_days >= 0
1175
1240
  ? config.log_retention_days
1176
1241
  : 14,
@@ -1189,6 +1254,18 @@ export function normalizeConfig(config) {
1189
1254
  builder_model_id: config.builder_model_id || "",
1190
1255
  };
1191
1256
  }
1257
+ function normalizeObsidianVaultDir(value) {
1258
+ if (value === undefined || value === null) {
1259
+ return defaultObsidianVaultDir();
1260
+ }
1261
+ if (typeof value !== "string") {
1262
+ return defaultObsidianVaultDir();
1263
+ }
1264
+ const trimmed = value.trim();
1265
+ if (trimmed === "")
1266
+ return "";
1267
+ return expandHome(trimmed);
1268
+ }
1192
1269
  function normalizeLocaleValue(value) {
1193
1270
  if (typeof value !== "string")
1194
1271
  return undefined;
@@ -1234,6 +1311,9 @@ function applySetupOptions(config, options) {
1234
1311
  if (options.logsDir) {
1235
1312
  next.logs_dir = expandHome(options.logsDir);
1236
1313
  }
1314
+ if (options.skillOutputsDir) {
1315
+ next.skill_outputs_dir = expandHome(options.skillOutputsDir);
1316
+ }
1237
1317
  if (options.chatModel) {
1238
1318
  next.chat_model_id = options.chatModel;
1239
1319
  }
@@ -1272,6 +1352,8 @@ function stringifyTomlConfig(config) {
1272
1352
  `memory_dir = ${tomlString(config.memory_dir)}`,
1273
1353
  `index_dir = ${tomlString(config.index_dir)}`,
1274
1354
  `logs_dir = ${tomlString(config.logs_dir)}`,
1355
+ `skill_outputs_dir = ${tomlString(config.skill_outputs_dir)}`,
1356
+ `obsidian_vault_dir = ${tomlString(config.obsidian_vault_dir ?? defaultObsidianVaultDir())}`,
1275
1357
  `log_retention_days = ${config.log_retention_days}`,
1276
1358
  `event_log_retention_days = ${config.event_log_retention_days}`,
1277
1359
  "",
@@ -19,3 +19,10 @@ export interface DailyMemoryPromotionResult {
19
19
  export declare function maybePromoteDailyMemory(config: AppConfig, options?: DailyMemoryPromotionOptions): Promise<DailyMemoryPromotionResult>;
20
20
  export declare function promoteDailyMemory(config: AppConfig, options?: DailyMemoryPromotionOptions): Promise<DailyMemoryPromotionResult>;
21
21
  export declare function parseDailyMemoryPromotionResponse(text: string): string[];
22
+ export declare function refreshRecentTopicsSection(config: AppConfig, input: {
23
+ endDate: string;
24
+ modelId: string;
25
+ eventSource: EventLogSource;
26
+ }): Promise<void>;
27
+ export declare function parseRecentTopicsResponse(text: string): string[];
28
+ export declare function removeRecentTopicsSection(text: string): string;