my-pi-agent 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 (141) hide show
  1. package/README.md +318 -0
  2. package/package.json +45 -0
  3. package/pyproject.toml +50 -0
  4. package/src/my_agent_core/__init__.py +123 -0
  5. package/src/my_agent_core/agent.py +441 -0
  6. package/src/my_agent_core/background.py +121 -0
  7. package/src/my_agent_core/context.py +505 -0
  8. package/src/my_agent_core/events.py +153 -0
  9. package/src/my_agent_core/extensions/__init__.py +9 -0
  10. package/src/my_agent_core/extensions/core.py +197 -0
  11. package/src/my_agent_core/hooks.py +130 -0
  12. package/src/my_agent_core/loop.py +709 -0
  13. package/src/my_agent_core/main.py +134 -0
  14. package/src/my_agent_core/memory.py +241 -0
  15. package/src/my_agent_core/message_queue.py +110 -0
  16. package/src/my_agent_core/plugins.py +212 -0
  17. package/src/my_agent_core/registry.py +186 -0
  18. package/src/my_agent_core/session/__init__.py +79 -0
  19. package/src/my_agent_core/session/entries.py +197 -0
  20. package/src/my_agent_core/session/jsonl.py +60 -0
  21. package/src/my_agent_core/session/memory.py +137 -0
  22. package/src/my_agent_core/session/session.py +400 -0
  23. package/src/my_agent_core/session/storage.py +245 -0
  24. package/src/my_agent_core/session/store.py +131 -0
  25. package/src/my_agent_core/session/tree.py +86 -0
  26. package/src/my_agent_core/skills.py +149 -0
  27. package/src/my_agent_core/subagent_tasks.py +170 -0
  28. package/src/my_agent_core/subagents.py +148 -0
  29. package/src/my_agent_core/task_store.py +248 -0
  30. package/src/my_agent_core/tool_history.py +189 -0
  31. package/src/my_agent_core/tools/__init__.py +5 -0
  32. package/src/my_agent_core/tools/builtin/__init__.py +5 -0
  33. package/src/my_agent_core/tools/builtin/task.py +30 -0
  34. package/src/my_agent_core/tools/builtin/task_tools.py +215 -0
  35. package/src/my_agent_core/tools/core.py +239 -0
  36. package/src/my_agent_llm/__init__.py +45 -0
  37. package/src/my_agent_llm/auth/__init__.py +46 -0
  38. package/src/my_agent_llm/auth/antigravity.py +209 -0
  39. package/src/my_agent_llm/auth/manager.py +259 -0
  40. package/src/my_agent_llm/auth/quota.py +56 -0
  41. package/src/my_agent_llm/auth/schema.py +94 -0
  42. package/src/my_agent_llm/client.py +116 -0
  43. package/src/my_agent_llm/config.py +17 -0
  44. package/src/my_agent_llm/events.py +84 -0
  45. package/src/my_agent_llm/models.py +195 -0
  46. package/src/my_agent_llm/providers/__init__.py +4 -0
  47. package/src/my_agent_llm/providers/_base.py +94 -0
  48. package/src/my_agent_llm/providers/anthropic.py +298 -0
  49. package/src/my_agent_llm/providers/antigravity.py +480 -0
  50. package/src/my_agent_llm/providers/deepseek.py +196 -0
  51. package/src/my_agent_llm/providers/openai.py +364 -0
  52. package/src/my_agent_llm/providers/registry.py +16 -0
  53. package/src/my_agent_llm/stream.py +218 -0
  54. package/src/my_coding_agent/__init__.py +66 -0
  55. package/src/my_coding_agent/agent.py +208 -0
  56. package/src/my_coding_agent/cli.py +78 -0
  57. package/src/my_coding_agent/file_reference.py +80 -0
  58. package/src/my_coding_agent/macro.py +408 -0
  59. package/src/my_coding_agent/mcp.py +243 -0
  60. package/src/my_coding_agent/mutation_queue.py +37 -0
  61. package/src/my_coding_agent/paths.py +119 -0
  62. package/src/my_coding_agent/permissions.py +84 -0
  63. package/src/my_coding_agent/prompt.py +54 -0
  64. package/src/my_coding_agent/rpc_server.py +2817 -0
  65. package/src/my_coding_agent/settings.py +126 -0
  66. package/src/my_coding_agent/tools/__init__.py +55 -0
  67. package/src/my_coding_agent/tools/base.py +58 -0
  68. package/src/my_coding_agent/tools/bash.py +206 -0
  69. package/src/my_coding_agent/tools/edit.py +226 -0
  70. package/src/my_coding_agent/tools/find.py +118 -0
  71. package/src/my_coding_agent/tools/grep.py +177 -0
  72. package/src/my_coding_agent/tools/ls.py +112 -0
  73. package/src/my_coding_agent/tools/read.py +113 -0
  74. package/src/my_coding_agent/tools/write.py +72 -0
  75. package/tui/README.md +27 -0
  76. package/tui/bin/my-agent.js +98 -0
  77. package/tui/dist/app.d.ts +41 -0
  78. package/tui/dist/app.js +110 -0
  79. package/tui/dist/bridge/event-translator.d.ts +92 -0
  80. package/tui/dist/bridge/event-translator.js +216 -0
  81. package/tui/dist/bridge/kernel-bridge.d.ts +48 -0
  82. package/tui/dist/bridge/kernel-bridge.js +132 -0
  83. package/tui/dist/client.d.ts +63 -0
  84. package/tui/dist/client.js +239 -0
  85. package/tui/dist/components/assistant-message.d.ts +19 -0
  86. package/tui/dist/components/assistant-message.js +90 -0
  87. package/tui/dist/components/compaction-summary-message.d.ts +19 -0
  88. package/tui/dist/components/compaction-summary-message.js +46 -0
  89. package/tui/dist/components/custom-editor.d.ts +18 -0
  90. package/tui/dist/components/custom-editor.js +56 -0
  91. package/tui/dist/components/dynamic-border.d.ts +9 -0
  92. package/tui/dist/components/dynamic-border.js +14 -0
  93. package/tui/dist/components/footer.d.ts +39 -0
  94. package/tui/dist/components/footer.js +199 -0
  95. package/tui/dist/components/header.d.ts +4 -0
  96. package/tui/dist/components/header.js +21 -0
  97. package/tui/dist/components/keys.d.ts +5 -0
  98. package/tui/dist/components/keys.js +12 -0
  99. package/tui/dist/components/login-selector.d.ts +26 -0
  100. package/tui/dist/components/login-selector.js +181 -0
  101. package/tui/dist/components/logout-selector.d.ts +19 -0
  102. package/tui/dist/components/logout-selector.js +88 -0
  103. package/tui/dist/components/model-selector.d.ts +40 -0
  104. package/tui/dist/components/model-selector.js +268 -0
  105. package/tui/dist/components/session-selector.d.ts +54 -0
  106. package/tui/dist/components/session-selector.js +393 -0
  107. package/tui/dist/components/settings-selector.d.ts +24 -0
  108. package/tui/dist/components/settings-selector.js +146 -0
  109. package/tui/dist/components/status-indicator.d.ts +25 -0
  110. package/tui/dist/components/status-indicator.js +60 -0
  111. package/tui/dist/components/theme-selector.d.ts +14 -0
  112. package/tui/dist/components/theme-selector.js +77 -0
  113. package/tui/dist/components/thinking-selector.d.ts +21 -0
  114. package/tui/dist/components/thinking-selector.js +128 -0
  115. package/tui/dist/components/tool-execution.d.ts +31 -0
  116. package/tui/dist/components/tool-execution.js +206 -0
  117. package/tui/dist/components/tree-selector.d.ts +40 -0
  118. package/tui/dist/components/tree-selector.js +173 -0
  119. package/tui/dist/components/user-message-selector.d.ts +21 -0
  120. package/tui/dist/components/user-message-selector.js +103 -0
  121. package/tui/dist/components/user-message.d.ts +5 -0
  122. package/tui/dist/components/user-message.js +15 -0
  123. package/tui/dist/index.d.ts +11 -0
  124. package/tui/dist/index.js +11 -0
  125. package/tui/dist/interactive/chat-viewport.d.ts +19 -0
  126. package/tui/dist/interactive/chat-viewport.js +41 -0
  127. package/tui/dist/interactive/components.d.ts +1 -0
  128. package/tui/dist/interactive/components.js +1 -0
  129. package/tui/dist/interactive/interactive-mode.d.ts +89 -0
  130. package/tui/dist/interactive/interactive-mode.js +1625 -0
  131. package/tui/dist/interactive/theme.d.ts +1 -0
  132. package/tui/dist/interactive/theme.js +1 -0
  133. package/tui/dist/interactive/tui-renderer.d.ts +8 -0
  134. package/tui/dist/interactive/tui-renderer.js +10 -0
  135. package/tui/dist/protocol.d.ts +78 -0
  136. package/tui/dist/protocol.js +1 -0
  137. package/tui/dist/theme/dark.json +54 -0
  138. package/tui/dist/theme/light.json +71 -0
  139. package/tui/dist/theme/theme.d.ts +20 -0
  140. package/tui/dist/theme/theme.js +86 -0
  141. package/tui/package.json +25 -0
@@ -0,0 +1 @@
1
+ export { getLanguageFromPath, getMarkdownTheme, getSelectListTheme, getSettingsListTheme, highlightCode, initTheme, Theme, } from "@earendil-works/pi-coding-agent";
@@ -0,0 +1 @@
1
+ export { getLanguageFromPath, getMarkdownTheme, getSelectListTheme, getSettingsListTheme, highlightCode, initTheme, Theme, } from "@earendil-works/pi-coding-agent";
@@ -0,0 +1,8 @@
1
+ import { type Terminal, TuiAltScreen, TuiMainScreen } from "@earendil-works/pi-tui";
2
+ export interface InteractiveTuiOptions {
3
+ readonly tuiMode?: "regular" | "fullscreen";
4
+ readonly showHardwareCursor?: boolean;
5
+ readonly logDirectory?: string;
6
+ readonly terminal?: Terminal;
7
+ }
8
+ export declare function createInteractiveTui(options?: InteractiveTuiOptions): TuiMainScreen | TuiAltScreen;
@@ -0,0 +1,10 @@
1
+ import { ProcessTerminal, TuiAltScreen, TuiMainScreen, } from "@earendil-works/pi-tui";
2
+ export function createInteractiveTui(options = {}) {
3
+ const terminal = options.terminal ?? new ProcessTerminal();
4
+ const showCursor = options.showHardwareCursor ?? false;
5
+ const logDir = options.logDirectory ?? "";
6
+ if (options.tuiMode === "fullscreen") {
7
+ return new TuiAltScreen(terminal, showCursor, logDir);
8
+ }
9
+ return new TuiMainScreen(terminal, showCursor, logDir);
10
+ }
@@ -0,0 +1,78 @@
1
+ export interface JsonRpcRequest {
2
+ jsonrpc: "2.0";
3
+ id: number | string;
4
+ method: string;
5
+ params?: Record<string, unknown>;
6
+ }
7
+ export interface JsonRpcResponse {
8
+ jsonrpc: "2.0";
9
+ id: number | string;
10
+ result?: unknown;
11
+ error?: {
12
+ code: number;
13
+ message: string;
14
+ data?: unknown;
15
+ };
16
+ }
17
+ export interface JsonRpcNotification {
18
+ jsonrpc: "2.0";
19
+ method: string;
20
+ params: Record<string, unknown>;
21
+ }
22
+ export interface ChatMessage {
23
+ role: "user" | "assistant" | "system" | "tool";
24
+ content: string;
25
+ }
26
+ export interface AgentStartEvent {
27
+ type: "agent_start";
28
+ system_prompt?: string;
29
+ user_input?: string;
30
+ }
31
+ export interface AgentEndEvent {
32
+ type: "agent_end";
33
+ iterations: number;
34
+ stop_reason: string;
35
+ final_text?: string;
36
+ }
37
+ export interface TurnStartEvent {
38
+ type: "turn_start";
39
+ iteration: number;
40
+ }
41
+ export interface TurnEndEvent {
42
+ type: "turn_end";
43
+ }
44
+ export interface MessageStartEvent {
45
+ type: "message_start";
46
+ message: ChatMessage;
47
+ }
48
+ export interface MessageUpdateEvent {
49
+ type: "message_update";
50
+ message: ChatMessage;
51
+ delta?: string;
52
+ reasoning_delta?: string;
53
+ }
54
+ export interface MessageEndEvent {
55
+ type: "message_end";
56
+ message: ChatMessage;
57
+ }
58
+ export interface ToolExecutionStartEvent {
59
+ type: "tool_execution_start";
60
+ toolCallId: string;
61
+ toolName: string;
62
+ args: Record<string, unknown>;
63
+ }
64
+ export interface ToolExecutionUpdateEvent {
65
+ type: "tool_execution_update";
66
+ toolCallId: string;
67
+ toolName: string;
68
+ args?: Record<string, unknown>;
69
+ partialResult: unknown;
70
+ }
71
+ export interface ToolExecutionEndEvent {
72
+ type: "tool_execution_end";
73
+ toolCallId: string;
74
+ toolName: string;
75
+ result: unknown;
76
+ isError: boolean;
77
+ }
78
+ export type AgentEvent = AgentStartEvent | AgentEndEvent | TurnStartEvent | TurnEndEvent | MessageStartEvent | MessageUpdateEvent | MessageEndEvent | ToolExecutionStartEvent | ToolExecutionUpdateEvent | ToolExecutionEndEvent;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "dark",
3
+ "vars": {
4
+ "cyan": "#00d7ff",
5
+ "blue": "#5f87ff",
6
+ "green": "#b5bd68",
7
+ "red": "#cc6666",
8
+ "yellow": "#ffff00",
9
+ "text": "#d4d4d4",
10
+ "gray": "#808080",
11
+ "dimGray": "#666666",
12
+ "darkGray": "#505050",
13
+ "accent": "#8abeb7",
14
+ "selectedBg": "#3a3a4a",
15
+ "userMsgBg": "#343541",
16
+ "toolPendingBg": "#282832",
17
+ "toolSuccessBg": "#283228",
18
+ "toolErrorBg": "#3c2828",
19
+ "customMsgBg": "#2d2838"
20
+ },
21
+ "colors": {
22
+ "accent": "accent",
23
+ "border": "blue",
24
+ "borderAccent": "cyan",
25
+ "borderMuted": "darkGray",
26
+ "success": "green",
27
+ "error": "red",
28
+ "warning": "yellow",
29
+ "muted": "gray",
30
+ "dim": "dimGray",
31
+ "text": "text",
32
+ "thinkingText": "gray",
33
+ "selectedBg": "selectedBg",
34
+ "userMessageBg": "userMsgBg",
35
+ "userMessageText": "text",
36
+ "customMessageBg": "customMsgBg",
37
+ "customMessageText": "text",
38
+ "toolPendingBg": "toolPendingBg",
39
+ "toolSuccessBg": "toolSuccessBg",
40
+ "toolErrorBg": "toolErrorBg",
41
+ "toolTitle": "text",
42
+ "toolOutput": "gray",
43
+ "mdHeading": "#f0c674",
44
+ "mdLink": "#81a2be",
45
+ "mdLinkUrl": "dimGray",
46
+ "mdCode": "accent",
47
+ "mdCodeBlock": "green",
48
+ "mdCodeBlockBorder": "gray",
49
+ "mdQuote": "gray",
50
+ "mdQuoteBorder": "gray",
51
+ "mdHr": "gray",
52
+ "mdListBullet": "accent"
53
+ }
54
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
3
+ "name": "light",
4
+ "vars": {
5
+ "teal": "#5a8080",
6
+ "blue": "#547da7",
7
+ "green": "#588458",
8
+ "red": "#aa5555",
9
+ "yellow": "#9a7326",
10
+ "text": "#1f2328",
11
+ "mediumGray": "#6c6c6c",
12
+ "dimGray": "#767676",
13
+ "lightGray": "#b0b0b0",
14
+ "selectedBg": "#d0d0e0",
15
+ "userMsgBg": "#e8e8e8",
16
+ "toolPendingBg": "#e8e8f0",
17
+ "toolSuccessBg": "#e8f0e8",
18
+ "toolErrorBg": "#f0e8e8",
19
+ "customMsgBg": "#ede7f6"
20
+ },
21
+ "colors": {
22
+ "accent": "teal",
23
+ "border": "blue",
24
+ "borderAccent": "teal",
25
+ "borderMuted": "lightGray",
26
+ "success": "green",
27
+ "error": "red",
28
+ "warning": "yellow",
29
+ "muted": "mediumGray",
30
+ "dim": "dimGray",
31
+ "text": "text",
32
+ "thinkingText": "mediumGray",
33
+ "selectedBg": "selectedBg",
34
+ "scrollbarTrack": "lightGray",
35
+ "scrollbarThumb": "text",
36
+ "searchMatchBg": "selectedBg",
37
+ "searchMatchText": "text",
38
+ "userMessageBg": "userMsgBg",
39
+ "userMessageText": "text",
40
+ "customMessageBg": "customMsgBg",
41
+ "customMessageText": "text",
42
+ "customMessageLabel": "#7e57c2",
43
+ "toolPendingBg": "toolPendingBg",
44
+ "toolSuccessBg": "toolSuccessBg",
45
+ "toolErrorBg": "toolErrorBg",
46
+ "toolTitle": "text",
47
+ "toolOutput": "mediumGray",
48
+ "mdHeading": "yellow",
49
+ "mdLink": "blue",
50
+ "mdLinkUrl": "dimGray",
51
+ "mdCode": "teal",
52
+ "mdCodeBlock": "green",
53
+ "mdCodeBlockBorder": "mediumGray",
54
+ "mdQuote": "mediumGray",
55
+ "mdQuoteBorder": "mediumGray",
56
+ "mdHr": "mediumGray",
57
+ "mdListBullet": "green",
58
+ "toolDiffAdded": "green",
59
+ "toolDiffRemoved": "red",
60
+ "toolDiffContext": "mediumGray",
61
+ "syntaxComment": "#008000",
62
+ "syntaxKeyword": "#0000FF",
63
+ "syntaxFunction": "#795E26",
64
+ "syntaxVariable": "#001080",
65
+ "syntaxString": "#A31515",
66
+ "syntaxNumber": "#098658",
67
+ "syntaxType": "#267F99",
68
+ "syntaxOperator": "#000000",
69
+ "syntaxPunctuation": "#000000"
70
+ }
71
+ }
@@ -0,0 +1,20 @@
1
+ import type { MarkdownTheme } from "@earendil-works/pi-tui";
2
+ export declare class ThemeManager {
3
+ private colors;
4
+ currentThemeName: string;
5
+ constructor();
6
+ setTheme(name: string): boolean;
7
+ load(json: {
8
+ vars: Record<string, string>;
9
+ colors: Record<string, string>;
10
+ }): void;
11
+ getHex(colorName: string): string;
12
+ fg(colorName: string, text: string): string;
13
+ bg(colorName: string, text: string): string;
14
+ bold(text: string): string;
15
+ italic(text: string): string;
16
+ dim(text: string): string;
17
+ getThinkingBorderColor(level: string): (str: string) => string;
18
+ }
19
+ export declare const theme: ThemeManager;
20
+ export declare function getMarkdownTheme(): MarkdownTheme;
@@ -0,0 +1,86 @@
1
+ import chalk from "chalk";
2
+ import darkJson from "./dark.json" with { type: "json" };
3
+ import lightJson from "./light.json" with { type: "json" };
4
+ export class ThemeManager {
5
+ colors = new Map();
6
+ currentThemeName = "dark";
7
+ constructor() {
8
+ this.load(darkJson);
9
+ }
10
+ setTheme(name) {
11
+ if (name === "light") {
12
+ this.load(lightJson);
13
+ this.currentThemeName = "light";
14
+ return true;
15
+ }
16
+ if (name === "dark") {
17
+ this.load(darkJson);
18
+ this.currentThemeName = "dark";
19
+ return true;
20
+ }
21
+ return false;
22
+ }
23
+ load(json) {
24
+ const vars = json.vars || {};
25
+ const colors = json.colors || {};
26
+ for (const [name, val] of Object.entries(colors)) {
27
+ const hex = vars[val] || val;
28
+ this.colors.set(name, hex);
29
+ }
30
+ }
31
+ getHex(colorName) {
32
+ return this.colors.get(colorName) || "#d4d4d4";
33
+ }
34
+ fg(colorName, text) {
35
+ const hex = this.getHex(colorName);
36
+ return chalk.hex(hex)(text);
37
+ }
38
+ bg(colorName, text) {
39
+ const hex = this.getHex(colorName);
40
+ return chalk.bgHex(hex)(text);
41
+ }
42
+ bold(text) {
43
+ return chalk.bold(text);
44
+ }
45
+ italic(text) {
46
+ return chalk.italic(text);
47
+ }
48
+ dim(text) {
49
+ return chalk.dim(text);
50
+ }
51
+ getThinkingBorderColor(level) {
52
+ const l = (level || "").toLowerCase();
53
+ if (l === "off") {
54
+ return (str) => this.fg("borderMuted", str);
55
+ }
56
+ if (l === "minimal" || l === "low") {
57
+ return (str) => this.fg("accent", str);
58
+ }
59
+ if (l === "medium") {
60
+ return (str) => this.fg("success", str);
61
+ }
62
+ if (l === "high" || l === "xhigh" || l === "max") {
63
+ return (str) => this.fg("warning", str);
64
+ }
65
+ return (str) => this.fg("borderMuted", str);
66
+ }
67
+ }
68
+ export const theme = new ThemeManager();
69
+ export function getMarkdownTheme() {
70
+ return {
71
+ heading: (text) => theme.bold(theme.fg("mdHeading", text)),
72
+ link: (text) => theme.fg("mdLink", text),
73
+ linkUrl: (text) => theme.fg("mdLinkUrl", text),
74
+ code: (text) => theme.fg("mdCode", text),
75
+ codeBlock: (text) => theme.fg("mdCodeBlock", text),
76
+ codeBlockBorder: (text) => theme.fg("mdCodeBlockBorder", text),
77
+ quote: (text) => theme.fg("mdQuote", text),
78
+ quoteBorder: (text) => theme.fg("mdQuoteBorder", text),
79
+ hr: (text) => theme.fg("mdHr", text),
80
+ listBullet: (text) => theme.fg("mdListBullet", text),
81
+ bold: (text) => theme.bold(text),
82
+ italic: (text) => theme.italic(text),
83
+ strikethrough: (text) => chalk.strikethrough(text),
84
+ underline: (text) => chalk.underline(text),
85
+ };
86
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "my-agent-tui",
3
+ "version": "0.1.0",
4
+ "description": "High-fidelity Pi-TUI terminal presentation layer for my-pi-agent",
5
+ "type": "module",
6
+ "bin": {
7
+ "my-agent": "./bin/my-agent.js",
8
+ "my-agent-tui": "./bin/my-agent.js"
9
+ },
10
+ "main": "dist/index.js",
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "test": "node --test test/*.test.js",
14
+ "start": "node bin/my-agent.js"
15
+ },
16
+ "dependencies": {
17
+ "@earendil-works/pi-tui": "^0.85.1",
18
+ "chalk": "^5.4.1",
19
+ "marked": "^15.0.7"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^22.13.10",
23
+ "typescript": "^5.8.2"
24
+ }
25
+ }