@gracefultools/astrid-sdk 0.7.16 → 0.8.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 (115) hide show
  1. package/README.md +127 -341
  2. package/dist/channel/channel.d.ts +33 -0
  3. package/dist/channel/channel.d.ts.map +1 -0
  4. package/dist/channel/channel.js +90 -0
  5. package/dist/channel/channel.js.map +1 -0
  6. package/dist/channel/index.d.ts +13 -0
  7. package/dist/channel/index.d.ts.map +1 -0
  8. package/dist/channel/index.js +23 -0
  9. package/dist/channel/index.js.map +1 -0
  10. package/dist/channel/message-formatter.d.ts +14 -0
  11. package/dist/channel/message-formatter.d.ts.map +1 -0
  12. package/dist/channel/message-formatter.js +71 -0
  13. package/dist/channel/message-formatter.js.map +1 -0
  14. package/dist/channel/oauth-client.d.ts +15 -0
  15. package/dist/channel/oauth-client.d.ts.map +1 -0
  16. package/dist/channel/oauth-client.js +45 -0
  17. package/dist/channel/oauth-client.js.map +1 -0
  18. package/dist/channel/rest-client.d.ts +16 -0
  19. package/dist/channel/rest-client.d.ts.map +1 -0
  20. package/dist/channel/rest-client.js +66 -0
  21. package/dist/channel/rest-client.js.map +1 -0
  22. package/dist/channel/session-mapper.d.ts +14 -0
  23. package/dist/channel/session-mapper.d.ts.map +1 -0
  24. package/dist/channel/session-mapper.js +37 -0
  25. package/dist/channel/session-mapper.js.map +1 -0
  26. package/dist/channel/sse-client.d.ts +31 -0
  27. package/dist/channel/sse-client.d.ts.map +1 -0
  28. package/dist/channel/sse-client.js +171 -0
  29. package/dist/channel/sse-client.js.map +1 -0
  30. package/dist/channel/types.d.ts +65 -0
  31. package/dist/channel/types.d.ts.map +1 -0
  32. package/dist/channel/types.js +3 -0
  33. package/dist/channel/types.js.map +1 -0
  34. package/dist/config/agent-workflow.js +7 -7
  35. package/dist/index.d.ts +1 -8
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +16 -30
  38. package/dist/index.js.map +1 -1
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/types/index.d.ts.map +1 -1
  41. package/dist/utils/agent-config.d.ts.map +1 -1
  42. package/dist/utils/agent-config.js +14 -0
  43. package/dist/utils/agent-config.js.map +1 -1
  44. package/openclaw.plugin.json +25 -0
  45. package/package.json +66 -77
  46. package/templates/.astrid.config.json +60 -60
  47. package/templates/ASTRID.template.md +74 -74
  48. package/dist/bin/cli.d.ts +0 -14
  49. package/dist/bin/cli.d.ts.map +0 -1
  50. package/dist/bin/cli.js +0 -1610
  51. package/dist/bin/cli.js.map +0 -1
  52. package/dist/executors/claude.d.ts +0 -65
  53. package/dist/executors/claude.d.ts.map +0 -1
  54. package/dist/executors/claude.js +0 -838
  55. package/dist/executors/claude.js.map +0 -1
  56. package/dist/executors/gemini.d.ts +0 -23
  57. package/dist/executors/gemini.d.ts.map +0 -1
  58. package/dist/executors/gemini.js +0 -558
  59. package/dist/executors/gemini.js.map +0 -1
  60. package/dist/executors/openai.d.ts +0 -17
  61. package/dist/executors/openai.d.ts.map +0 -1
  62. package/dist/executors/openai.js +0 -614
  63. package/dist/executors/openai.js.map +0 -1
  64. package/dist/executors/shared/index.d.ts +0 -9
  65. package/dist/executors/shared/index.d.ts.map +0 -1
  66. package/dist/executors/shared/index.js +0 -21
  67. package/dist/executors/shared/index.js.map +0 -1
  68. package/dist/executors/shared/tool-executor.d.ts +0 -52
  69. package/dist/executors/shared/tool-executor.d.ts.map +0 -1
  70. package/dist/executors/shared/tool-executor.js +0 -262
  71. package/dist/executors/shared/tool-executor.js.map +0 -1
  72. package/dist/executors/shared/tool-schemas.d.ts +0 -61
  73. package/dist/executors/shared/tool-schemas.d.ts.map +0 -1
  74. package/dist/executors/shared/tool-schemas.js +0 -135
  75. package/dist/executors/shared/tool-schemas.js.map +0 -1
  76. package/dist/executors/terminal-base.d.ts +0 -207
  77. package/dist/executors/terminal-base.d.ts.map +0 -1
  78. package/dist/executors/terminal-base.js +0 -552
  79. package/dist/executors/terminal-base.js.map +0 -1
  80. package/dist/executors/terminal-claude.d.ts +0 -116
  81. package/dist/executors/terminal-claude.d.ts.map +0 -1
  82. package/dist/executors/terminal-claude.js +0 -700
  83. package/dist/executors/terminal-claude.js.map +0 -1
  84. package/dist/executors/terminal-executors.test.d.ts +0 -8
  85. package/dist/executors/terminal-executors.test.d.ts.map +0 -1
  86. package/dist/executors/terminal-executors.test.js +0 -469
  87. package/dist/executors/terminal-executors.test.js.map +0 -1
  88. package/dist/executors/terminal-gemini.d.ts +0 -50
  89. package/dist/executors/terminal-gemini.d.ts.map +0 -1
  90. package/dist/executors/terminal-gemini.js +0 -401
  91. package/dist/executors/terminal-gemini.js.map +0 -1
  92. package/dist/executors/terminal-openai.d.ts +0 -50
  93. package/dist/executors/terminal-openai.d.ts.map +0 -1
  94. package/dist/executors/terminal-openai.js +0 -405
  95. package/dist/executors/terminal-openai.js.map +0 -1
  96. package/dist/server/astrid-client.d.ts +0 -77
  97. package/dist/server/astrid-client.d.ts.map +0 -1
  98. package/dist/server/astrid-client.js +0 -125
  99. package/dist/server/astrid-client.js.map +0 -1
  100. package/dist/server/index.d.ts +0 -38
  101. package/dist/server/index.d.ts.map +0 -1
  102. package/dist/server/index.js +0 -408
  103. package/dist/server/index.js.map +0 -1
  104. package/dist/server/repo-manager.d.ts +0 -41
  105. package/dist/server/repo-manager.d.ts.map +0 -1
  106. package/dist/server/repo-manager.js +0 -177
  107. package/dist/server/repo-manager.js.map +0 -1
  108. package/dist/server/session-manager.d.ts +0 -93
  109. package/dist/server/session-manager.d.ts.map +0 -1
  110. package/dist/server/session-manager.js +0 -217
  111. package/dist/server/session-manager.js.map +0 -1
  112. package/dist/server/webhook-signature.d.ts +0 -23
  113. package/dist/server/webhook-signature.d.ts.map +0 -1
  114. package/dist/server/webhook-signature.js +0 -74
  115. package/dist/server/webhook-signature.js.map +0 -1
@@ -1,207 +0,0 @@
1
- /**
2
- * Terminal Executor Base Interface
3
- *
4
- * Common interface for all terminal executors (Claude, OpenAI, Gemini).
5
- * Terminal mode executes tasks using local tools instead of remote APIs.
6
- */
7
- import type { Session } from '../server/session-manager.js';
8
- /**
9
- * Result from terminal execution
10
- */
11
- export interface TerminalExecutionResult {
12
- exitCode: number | null;
13
- stdout: string;
14
- stderr: string;
15
- sessionId?: string;
16
- gitDiff?: string;
17
- modifiedFiles?: string[];
18
- prUrl?: string;
19
- }
20
- /**
21
- * Context for terminal task execution
22
- */
23
- export interface TerminalTaskContext {
24
- comments?: Array<{
25
- authorName: string;
26
- content: string;
27
- createdAt: string;
28
- }>;
29
- prUrl?: string;
30
- repository?: string;
31
- }
32
- /**
33
- * Parsed output from terminal execution
34
- */
35
- export interface ParsedOutput {
36
- summary?: string;
37
- files?: string[];
38
- prUrl?: string;
39
- error?: string;
40
- }
41
- /**
42
- * Progress callback function
43
- */
44
- export type TerminalProgressCallback = (message: string) => void;
45
- /**
46
- * Comment callback function for posting updates to the task
47
- */
48
- export type TerminalCommentCallback = (content: string) => Promise<void>;
49
- /**
50
- * Options for terminal executor callbacks
51
- */
52
- export interface TerminalExecutorCallbacks {
53
- onProgress?: TerminalProgressCallback;
54
- onComment?: TerminalCommentCallback;
55
- }
56
- /**
57
- * Common interface for all terminal executors.
58
- *
59
- * Terminal executors process tasks using local tool execution:
60
- * - Claude: Spawns local Claude Code CLI
61
- * - OpenAI: Uses OpenAI API with local tool execution
62
- * - Gemini: Uses Gemini API with local tool execution
63
- */
64
- export interface TerminalExecutor {
65
- /**
66
- * Check if the executor is available (e.g., CLI installed, API key set)
67
- */
68
- checkAvailable(): Promise<boolean>;
69
- /**
70
- * Start a new session to process a task
71
- *
72
- * @param session - The session containing task details
73
- * @param prompt - Optional custom prompt (uses default if not provided)
74
- * @param context - Optional context including comments and PR info
75
- * @param callbacks - Optional callbacks for progress updates and comments
76
- * @returns Execution result with output, modified files, and PR URL
77
- */
78
- startSession(session: Session, prompt?: string, context?: TerminalTaskContext, callbacks?: TerminalExecutorCallbacks): Promise<TerminalExecutionResult>;
79
- /**
80
- * Resume an existing session with new input
81
- *
82
- * @param session - The session to resume
83
- * @param input - New input from user (e.g., follow-up message)
84
- * @param context - Optional updated context
85
- * @param callbacks - Optional callbacks for progress updates and comments
86
- * @returns Execution result
87
- */
88
- resumeSession(session: Session, input: string, context?: TerminalTaskContext, callbacks?: TerminalExecutorCallbacks): Promise<TerminalExecutionResult>;
89
- /**
90
- * Parse output to extract key information
91
- *
92
- * @param output - Raw output string from execution
93
- * @returns Parsed output with summary, files, PR URL, and error
94
- */
95
- parseOutput(output: string): ParsedOutput;
96
- }
97
- /**
98
- * Extract PR URL from output text
99
- */
100
- export declare function extractPrUrl(output: string): string | undefined;
101
- /**
102
- * Format comment history for context
103
- */
104
- export declare function formatCommentHistory(comments?: TerminalTaskContext['comments']): string;
105
- /**
106
- * Capture current git status (untracked and modified files)
107
- * Call this BEFORE task execution to get baseline
108
- */
109
- export declare function captureGitBaseline(projectPath: string): Promise<Set<string>>;
110
- /**
111
- * Capture git changes in a repository
112
- * If baseline is provided, only returns NEW changes (not pre-existing)
113
- */
114
- export declare function captureGitChanges(projectPath: string, baseline?: Set<string>): Promise<{
115
- diff: string;
116
- files: string[];
117
- }>;
118
- /**
119
- * Build default prompt for a task
120
- */
121
- export declare function buildDefaultPrompt(session: Session, context?: TerminalTaskContext): string;
122
- /**
123
- * Types of content detected in Claude's output
124
- */
125
- export type OutputContentType = 'plan' | 'question' | 'progress' | 'error' | 'pr_created';
126
- /**
127
- * Detected content from parsing output
128
- */
129
- export interface DetectedContent {
130
- type: OutputContentType;
131
- content: string;
132
- raw?: string;
133
- }
134
- /**
135
- * Parser state for accumulating output across chunks
136
- */
137
- export interface OutputParserState {
138
- buffer: string;
139
- lastPlanPosted: number;
140
- lastProgressPosted: number;
141
- lastQuestionPosted: number;
142
- postedPlans: Set<string>;
143
- postedQuestions: Set<string>;
144
- }
145
- /**
146
- * Create a new parser state
147
- */
148
- export declare function createParserState(): OutputParserState;
149
- /**
150
- * Parse a chunk of output and detect any plans, questions, or progress updates.
151
- * Uses the state to track what's been posted to avoid duplicates.
152
- *
153
- * @param chunk - New output chunk to parse
154
- * @param state - Parser state for tracking
155
- * @returns Array of detected content items
156
- */
157
- export declare function parseOutputChunk(chunk: string, state: OutputParserState): DetectedContent[];
158
- /**
159
- * Format detected content as a comment for posting
160
- */
161
- export declare function formatContentAsComment(content: DetectedContent, agentName?: string): string;
162
- /**
163
- * Configuration for worktree isolation
164
- */
165
- export interface WorktreeConfig {
166
- /** Enable worktree isolation (default: true for safety) */
167
- enabled: boolean;
168
- /** Base directory for worktrees (default: /tmp/astrid-worktrees) */
169
- baseDir: string;
170
- /** Clean up worktrees after completion (default: true) */
171
- autoCleanup: boolean;
172
- }
173
- /**
174
- * Get worktree configuration from environment variables
175
- */
176
- export declare function getWorktreeConfig(): WorktreeConfig;
177
- /**
178
- * Result from creating a worktree
179
- */
180
- export interface WorktreeResult {
181
- /** Path to the worktree directory */
182
- worktreePath: string;
183
- /** Branch name created for this worktree */
184
- branchName: string;
185
- /** Cleanup function to remove the worktree */
186
- cleanup: () => Promise<void>;
187
- }
188
- /**
189
- * Create an isolated git worktree for a task.
190
- * This allows the agent to work on changes without affecting the main working directory.
191
- *
192
- * @param projectPath - Path to the main git repository
193
- * @param taskId - Task ID for naming the worktree and branch
194
- * @param branchPrefix - Prefix for the branch name (default: 'task/')
195
- * @returns WorktreeResult with path and cleanup function
196
- */
197
- export declare function createWorktree(projectPath: string, taskId: string, branchPrefix?: string): Promise<WorktreeResult>;
198
- /**
199
- * Check if worktree isolation should be used
200
- */
201
- export declare function shouldUseWorktree(): boolean;
202
- /**
203
- * Push changes from worktree and create PR
204
- * Returns the PR URL if successful
205
- */
206
- export declare function pushWorktreeChanges(worktreePath: string, branchName: string, taskTitle: string): Promise<string | undefined>;
207
- //# sourceMappingURL=terminal-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal-base.d.ts","sourceRoot":"","sources":["../../src/executors/terminal-base.ts"],"names":[],"mappings":"AAAA;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