agent-sin 0.1.0

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 (150) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +21 -0
  3. package/README.md +81 -0
  4. package/assets/logo.png +0 -0
  5. package/builtin-skills/_shared/_models_lib.py +227 -0
  6. package/builtin-skills/_shared/_profile_lib.py +98 -0
  7. package/builtin-skills/_shared/_schedules_lib.py +313 -0
  8. package/builtin-skills/_shared/_skill_settings_lib.py +153 -0
  9. package/builtin-skills/_shared/i18n.py +26 -0
  10. package/builtin-skills/memo-delete/main.py +155 -0
  11. package/builtin-skills/memo-delete/skill.yaml +57 -0
  12. package/builtin-skills/memo-index/main.py +178 -0
  13. package/builtin-skills/memo-index/skill.yaml +53 -0
  14. package/builtin-skills/memo-save/README.md +5 -0
  15. package/builtin-skills/memo-save/main.py +74 -0
  16. package/builtin-skills/memo-save/skill.yaml +52 -0
  17. package/builtin-skills/memo-search/README.md +10 -0
  18. package/builtin-skills/memo-search/main.py +97 -0
  19. package/builtin-skills/memo-search/skill.yaml +51 -0
  20. package/builtin-skills/memo-vector-search/main.py +121 -0
  21. package/builtin-skills/memo-vector-search/skill.yaml +53 -0
  22. package/builtin-skills/model-add/main.py +180 -0
  23. package/builtin-skills/model-add/skill.yaml +112 -0
  24. package/builtin-skills/model-list/main.py +93 -0
  25. package/builtin-skills/model-list/skill.yaml +48 -0
  26. package/builtin-skills/model-set/main.py +123 -0
  27. package/builtin-skills/model-set/skill.yaml +69 -0
  28. package/builtin-skills/profile-delete/_profile_lib.py +98 -0
  29. package/builtin-skills/profile-delete/main.py +98 -0
  30. package/builtin-skills/profile-delete/skill.yaml +64 -0
  31. package/builtin-skills/profile-edit/_profile_lib.py +98 -0
  32. package/builtin-skills/profile-edit/main.py +97 -0
  33. package/builtin-skills/profile-edit/skill.yaml +72 -0
  34. package/builtin-skills/profile-save/main.py +52 -0
  35. package/builtin-skills/profile-save/skill.yaml +69 -0
  36. package/builtin-skills/schedule-add/_schedules_lib.py +303 -0
  37. package/builtin-skills/schedule-add/main.py +137 -0
  38. package/builtin-skills/schedule-add/skill.yaml +94 -0
  39. package/builtin-skills/schedule-list/_schedules_lib.py +303 -0
  40. package/builtin-skills/schedule-list/main.py +86 -0
  41. package/builtin-skills/schedule-list/skill.yaml +45 -0
  42. package/builtin-skills/schedule-remove/_schedules_lib.py +303 -0
  43. package/builtin-skills/schedule-remove/main.py +69 -0
  44. package/builtin-skills/schedule-remove/skill.yaml +49 -0
  45. package/builtin-skills/schedule-toggle/_schedules_lib.py +303 -0
  46. package/builtin-skills/schedule-toggle/main.py +78 -0
  47. package/builtin-skills/schedule-toggle/skill.yaml +61 -0
  48. package/builtin-skills/skills-disable/main.py +63 -0
  49. package/builtin-skills/skills-disable/skill.yaml +52 -0
  50. package/builtin-skills/skills-enable/main.py +62 -0
  51. package/builtin-skills/skills-enable/skill.yaml +51 -0
  52. package/builtin-skills/todo-add/main.py +68 -0
  53. package/builtin-skills/todo-add/skill.yaml +53 -0
  54. package/builtin-skills/todo-delete/main.py +65 -0
  55. package/builtin-skills/todo-delete/skill.yaml +47 -0
  56. package/builtin-skills/todo-done/main.py +75 -0
  57. package/builtin-skills/todo-done/skill.yaml +47 -0
  58. package/builtin-skills/todo-list/main.py +91 -0
  59. package/builtin-skills/todo-list/skill.yaml +48 -0
  60. package/builtin-skills/todo-tick/main.py +125 -0
  61. package/builtin-skills/todo-tick/skill.yaml +48 -0
  62. package/dist/builder/build-action-classifier.d.ts +18 -0
  63. package/dist/builder/build-action-classifier.js +142 -0
  64. package/dist/builder/build-commands.d.ts +19 -0
  65. package/dist/builder/build-commands.js +133 -0
  66. package/dist/builder/build-flow.d.ts +72 -0
  67. package/dist/builder/build-flow.js +416 -0
  68. package/dist/builder/builder-session.d.ts +117 -0
  69. package/dist/builder/builder-session.js +1129 -0
  70. package/dist/builder/conversation-router.d.ts +22 -0
  71. package/dist/builder/conversation-router.js +69 -0
  72. package/dist/builder/intent-runtime-store.d.ts +7 -0
  73. package/dist/builder/intent-runtime-store.js +60 -0
  74. package/dist/builder/progress-format.d.ts +7 -0
  75. package/dist/builder/progress-format.js +46 -0
  76. package/dist/cli/index.d.ts +2 -0
  77. package/dist/cli/index.js +2835 -0
  78. package/dist/cli/spinner.d.ts +30 -0
  79. package/dist/cli/spinner.js +164 -0
  80. package/dist/core/ai-provider.d.ts +75 -0
  81. package/dist/core/ai-provider.js +678 -0
  82. package/dist/core/builtin-skills.d.ts +27 -0
  83. package/dist/core/builtin-skills.js +120 -0
  84. package/dist/core/chat-engine.d.ts +70 -0
  85. package/dist/core/chat-engine.js +812 -0
  86. package/dist/core/config.d.ts +127 -0
  87. package/dist/core/config.js +1379 -0
  88. package/dist/core/daily-memory-promotion.d.ts +21 -0
  89. package/dist/core/daily-memory-promotion.js +422 -0
  90. package/dist/core/i18n.d.ts +23 -0
  91. package/dist/core/i18n.js +167 -0
  92. package/dist/core/info-lines.d.ts +5 -0
  93. package/dist/core/info-lines.js +39 -0
  94. package/dist/core/input-schema.d.ts +2 -0
  95. package/dist/core/input-schema.js +156 -0
  96. package/dist/core/intent-router.d.ts +27 -0
  97. package/dist/core/intent-router.js +160 -0
  98. package/dist/core/logger.d.ts +60 -0
  99. package/dist/core/logger.js +240 -0
  100. package/dist/core/memory.d.ts +10 -0
  101. package/dist/core/memory.js +72 -0
  102. package/dist/core/message-utils.d.ts +13 -0
  103. package/dist/core/message-utils.js +104 -0
  104. package/dist/core/notifier.d.ts +17 -0
  105. package/dist/core/notifier.js +424 -0
  106. package/dist/core/output-writer.d.ts +13 -0
  107. package/dist/core/output-writer.js +100 -0
  108. package/dist/core/plan-decision.d.ts +16 -0
  109. package/dist/core/plan-decision.js +88 -0
  110. package/dist/core/profile-memory.d.ts +17 -0
  111. package/dist/core/profile-memory.js +142 -0
  112. package/dist/core/runtime.d.ts +50 -0
  113. package/dist/core/runtime.js +187 -0
  114. package/dist/core/scheduler.d.ts +28 -0
  115. package/dist/core/scheduler.js +155 -0
  116. package/dist/core/secrets.d.ts +31 -0
  117. package/dist/core/secrets.js +214 -0
  118. package/dist/core/service.d.ts +35 -0
  119. package/dist/core/service.js +479 -0
  120. package/dist/core/skill-planner.d.ts +24 -0
  121. package/dist/core/skill-planner.js +100 -0
  122. package/dist/core/skill-registry.d.ts +98 -0
  123. package/dist/core/skill-registry.js +319 -0
  124. package/dist/core/skill-scaffold.d.ts +33 -0
  125. package/dist/core/skill-scaffold.js +256 -0
  126. package/dist/core/skill-settings.d.ts +11 -0
  127. package/dist/core/skill-settings.js +63 -0
  128. package/dist/core/transfer.d.ts +31 -0
  129. package/dist/core/transfer.js +270 -0
  130. package/dist/core/update-notifier.d.ts +2 -0
  131. package/dist/core/update-notifier.js +140 -0
  132. package/dist/discord/bot.d.ts +96 -0
  133. package/dist/discord/bot.js +2424 -0
  134. package/dist/runtimes/codex-app-server.d.ts +53 -0
  135. package/dist/runtimes/codex-app-server.js +305 -0
  136. package/dist/runtimes/python-runner.d.ts +7 -0
  137. package/dist/runtimes/python-runner.js +302 -0
  138. package/dist/runtimes/typescript-runner.d.ts +5 -0
  139. package/dist/runtimes/typescript-runner.js +172 -0
  140. package/dist/skills-sdk/types.d.ts +38 -0
  141. package/dist/skills-sdk/types.js +1 -0
  142. package/dist/telegram/bot.d.ts +94 -0
  143. package/dist/telegram/bot.js +1219 -0
  144. package/install.ps1 +132 -0
  145. package/install.sh +130 -0
  146. package/package.json +60 -0
  147. package/templates/skill-python/main.py +74 -0
  148. package/templates/skill-python/skill.yaml +48 -0
  149. package/templates/skill-typescript/main.ts +87 -0
  150. package/templates/skill-typescript/skill.yaml +42 -0
@@ -0,0 +1,27 @@
1
+ export interface BuiltinMigrationReport {
2
+ /** ids whose workspace copy matched the packaged version and was silently removed. */
3
+ deleted: string[];
4
+ /** ids whose workspace copy differed from the packaged version and was moved aside. */
5
+ archived: Array<{
6
+ id: string;
7
+ archivePath: string;
8
+ }>;
9
+ /** ids whose workspace copy is kept as an explicit override (`override: true`). */
10
+ retained: string[];
11
+ }
12
+ /**
13
+ * Migrate legacy in-workspace copies of builtin skills.
14
+ *
15
+ * Builtin skills are now loaded directly from the packaged `builtin-skills/`
16
+ * directory; the user's workspace `skills/` is for user-authored skills only.
17
+ * Existing installs may still have stale copies of builtin skills under
18
+ * `<skills_dir>/<builtin-id>/`. For each such directory we:
19
+ *
20
+ * - Skip it if its `skill.yaml` has `override: true` (deliberate override).
21
+ * - Delete it silently if every file matches the packaged version byte-for-byte.
22
+ * - Move it to `<skills_dir>/.archived-builtin-overrides/<id>/<timestamp>/`
23
+ * otherwise, so user customisation is never silently lost.
24
+ *
25
+ * Safe to call repeatedly; returns a report describing what happened.
26
+ */
27
+ export declare function migrateLegacyBuiltinCopies(skillsDir: string): Promise<BuiltinMigrationReport>;
@@ -0,0 +1,120 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir, readFile, readdir, rename, rm, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import YAML from "yaml";
5
+ import { builtinSkillsDir, listBuiltinSkillIds } from "./skill-registry.js";
6
+ /**
7
+ * Migrate legacy in-workspace copies of builtin skills.
8
+ *
9
+ * Builtin skills are now loaded directly from the packaged `builtin-skills/`
10
+ * directory; the user's workspace `skills/` is for user-authored skills only.
11
+ * Existing installs may still have stale copies of builtin skills under
12
+ * `<skills_dir>/<builtin-id>/`. For each such directory we:
13
+ *
14
+ * - Skip it if its `skill.yaml` has `override: true` (deliberate override).
15
+ * - Delete it silently if every file matches the packaged version byte-for-byte.
16
+ * - Move it to `<skills_dir>/.archived-builtin-overrides/<id>/<timestamp>/`
17
+ * otherwise, so user customisation is never silently lost.
18
+ *
19
+ * Safe to call repeatedly; returns a report describing what happened.
20
+ */
21
+ export async function migrateLegacyBuiltinCopies(skillsDir) {
22
+ const report = { deleted: [], archived: [], retained: [] };
23
+ const builtinIds = await listBuiltinSkillIds();
24
+ if (builtinIds.size === 0) {
25
+ return report;
26
+ }
27
+ const builtinRoot = builtinSkillsDir();
28
+ for (const id of builtinIds) {
29
+ const workspacePath = path.join(skillsDir, id);
30
+ const workspaceManifest = path.join(workspacePath, "skill.yaml");
31
+ try {
32
+ await stat(workspaceManifest);
33
+ }
34
+ catch {
35
+ continue;
36
+ }
37
+ if (await hasOverrideFlag(workspaceManifest)) {
38
+ report.retained.push(id);
39
+ continue;
40
+ }
41
+ const builtinPath = path.join(builtinRoot, id);
42
+ const identical = await directoriesIdentical(workspacePath, builtinPath);
43
+ if (identical) {
44
+ await rm(workspacePath, { recursive: true, force: true });
45
+ report.deleted.push(id);
46
+ continue;
47
+ }
48
+ const archiveRoot = path.join(skillsDir, ".archived-builtin-overrides", id);
49
+ await mkdir(archiveRoot, { recursive: true });
50
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
51
+ const archivePath = path.join(archiveRoot, stamp);
52
+ await rename(workspacePath, archivePath);
53
+ report.archived.push({ id, archivePath });
54
+ }
55
+ return report;
56
+ }
57
+ async function hasOverrideFlag(manifestPath) {
58
+ try {
59
+ const raw = await readFile(manifestPath, "utf8");
60
+ const parsed = YAML.parse(raw);
61
+ return parsed?.override === true;
62
+ }
63
+ catch {
64
+ return false;
65
+ }
66
+ }
67
+ async function directoriesIdentical(a, b) {
68
+ let filesA;
69
+ let filesB;
70
+ try {
71
+ filesA = (await collectFiles(a)).sort();
72
+ filesB = (await collectFiles(b)).sort();
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ if (filesA.length !== filesB.length) {
78
+ return false;
79
+ }
80
+ for (let i = 0; i < filesA.length; i += 1) {
81
+ if (filesA[i] !== filesB[i]) {
82
+ return false;
83
+ }
84
+ }
85
+ for (const relative of filesA) {
86
+ const hashA = await hashFile(path.join(a, relative));
87
+ const hashB = await hashFile(path.join(b, relative));
88
+ if (hashA !== hashB) {
89
+ return false;
90
+ }
91
+ }
92
+ return true;
93
+ }
94
+ async function collectFiles(root) {
95
+ const out = [];
96
+ await walk(root, root, out);
97
+ return out;
98
+ }
99
+ async function walk(root, current, out) {
100
+ let entries;
101
+ try {
102
+ entries = await readdir(current, { withFileTypes: true });
103
+ }
104
+ catch {
105
+ return;
106
+ }
107
+ for (const entry of entries) {
108
+ const full = path.join(current, entry.name);
109
+ if (entry.isDirectory()) {
110
+ await walk(root, full, out);
111
+ }
112
+ else if (entry.isFile()) {
113
+ out.push(path.relative(root, full));
114
+ }
115
+ }
116
+ }
117
+ async function hashFile(file) {
118
+ const data = await readFile(file);
119
+ return createHash("sha256").update(data).digest("hex");
120
+ }
@@ -0,0 +1,70 @@
1
+ import { type AppConfig } from "./config.js";
2
+ import { type EventLogSource } from "./logger.js";
3
+ import { type AiImagePart, type AiMessage, type AiProgressEvent, type AiProgressHandler } from "./ai-provider.js";
4
+ import { type SkillManifest } from "./skill-registry.js";
5
+ import { type ProfileMemoryFiles } from "./profile-memory.js";
6
+ export type ChatRole = "user" | "assistant" | "tool";
7
+ export interface ChatTurn {
8
+ role: ChatRole;
9
+ content: string;
10
+ }
11
+ export interface SkillCall {
12
+ id: string;
13
+ args: Record<string, unknown>;
14
+ }
15
+ export interface ChatBuildSuggestion {
16
+ type: "create" | "edit";
17
+ skill_id: string;
18
+ reason?: string;
19
+ }
20
+ export interface SpinnerLike {
21
+ isActive(): boolean;
22
+ start(label: string): void;
23
+ update(label: string): void;
24
+ stop(): void;
25
+ }
26
+ export type ChatProgressEvent = {
27
+ kind: "thinking";
28
+ iteration: number;
29
+ } | {
30
+ kind: "tool_running";
31
+ skill_id: string;
32
+ } | {
33
+ kind: "tool_repairing";
34
+ skill_id: string;
35
+ } | {
36
+ kind: "tool_done";
37
+ skill_id: string;
38
+ status: string;
39
+ } | {
40
+ kind: "model_failed";
41
+ message: string;
42
+ };
43
+ export interface ChatRespondOptions {
44
+ formatNarrative?: (text: string) => string;
45
+ spinner?: SpinnerLike;
46
+ eventSource?: EventLogSource;
47
+ onChatProgress?: (event: ChatProgressEvent) => void;
48
+ onAiProgress?: AiProgressHandler;
49
+ onBuildSuggestion?: (suggestion: ChatBuildSuggestion) => void;
50
+ preferredSkillId?: string;
51
+ userImages?: AiImagePart[];
52
+ }
53
+ export declare const HISTORY_LIMIT = 20;
54
+ export declare const TOOL_CALL_MAX_ITERATIONS = 3;
55
+ export declare function chatRespond(config: AppConfig, userText: string, history: ChatTurn[], options?: ChatRespondOptions): Promise<string[]>;
56
+ export declare function makeSpinnerProgress(spinner: SpinnerLike, baseLabel: string): (event: AiProgressEvent) => void;
57
+ export declare function formatProgressLabel(baseLabel: string, event: AiProgressEvent): string | null;
58
+ export declare function isToolEligible(skill: SkillManifest): boolean;
59
+ export declare function buildSystemPrompt(skills: SkillManifest[], preferredSkillId?: string, profileMemory?: ProfileMemoryFiles): string;
60
+ export declare function parseSkillCalls(text: string): SkillCall[];
61
+ export declare function stripSkillCalls(text: string): string;
62
+ export declare function extractSkillCallBlocks(text: string): string;
63
+ export declare function parseBuildSuggestion(text: string): ChatBuildSuggestion | null;
64
+ export declare function stripBuildSuggestions(text: string): string;
65
+ export declare function toolResultJson(id: string, status: string, summary: string, saved?: string[], data?: unknown): string;
66
+ export declare function toAiMessages(history: ChatTurn[], multimodalTurn?: {
67
+ index: number;
68
+ images: AiImagePart[];
69
+ }): AiMessage[];
70
+ export declare function appendHistory(history: ChatTurn[], turn: ChatTurn): void;