aws-runtime-bridge 1.9.10 → 1.9.20

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 (121) hide show
  1. package/dist/adapter/AcodeSdkAdapter.d.ts +40 -0
  2. package/dist/adapter/AcodeSdkAdapter.d.ts.map +1 -1
  3. package/dist/adapter/AcodeSdkAdapter.js +353 -7
  4. package/dist/adapter/AcodeSdkAdapter.test.js +155 -8
  5. package/dist/adapter/OpencodeSdkAdapter.d.ts.map +1 -1
  6. package/dist/adapter/OpencodeSdkAdapter.js +36 -3
  7. package/dist/adapter/instance-ai-config-resolver.d.ts +49 -0
  8. package/dist/adapter/instance-ai-config-resolver.d.ts.map +1 -0
  9. package/dist/adapter/instance-ai-config-resolver.js +46 -0
  10. package/dist/adapter/types.d.ts +27 -2
  11. package/dist/adapter/types.d.ts.map +1 -1
  12. package/dist/index.js +5 -1
  13. package/dist/routes/dashboard.d.ts.map +1 -1
  14. package/dist/routes/dashboard.js +749 -15
  15. package/dist/routes/events.d.ts +7 -0
  16. package/dist/routes/events.d.ts.map +1 -0
  17. package/dist/routes/events.js +22 -0
  18. package/dist/routes/file-browser.d.ts +1 -1
  19. package/dist/routes/file-browser.d.ts.map +1 -1
  20. package/dist/routes/file-browser.js +25 -9
  21. package/dist/routes/file-snapshot.d.ts +10 -0
  22. package/dist/routes/file-snapshot.d.ts.map +1 -0
  23. package/dist/routes/file-snapshot.js +156 -0
  24. package/dist/routes/git.d.ts +10 -0
  25. package/dist/routes/git.d.ts.map +1 -1
  26. package/dist/routes/git.js +305 -2
  27. package/dist/routes/git.test.js +39 -2
  28. package/dist/routes/instance.js +3 -1
  29. package/dist/routes/memory.d.ts +3 -0
  30. package/dist/routes/memory.d.ts.map +1 -1
  31. package/dist/routes/memory.js +3 -0
  32. package/dist/routes/terminal.d.ts +2 -1
  33. package/dist/routes/terminal.d.ts.map +1 -1
  34. package/dist/routes/terminal.js +378 -41
  35. package/dist/routes/terminal.test.js +33 -7
  36. package/dist/services/agent-event-store.d.ts +59 -0
  37. package/dist/services/agent-event-store.d.ts.map +1 -0
  38. package/dist/services/agent-event-store.js +68 -0
  39. package/dist/services/event-delta-pusher.d.ts +40 -0
  40. package/dist/services/event-delta-pusher.d.ts.map +1 -0
  41. package/dist/services/event-delta-pusher.js +95 -0
  42. package/dist/services/fileSnapshotStore.d.ts +96 -0
  43. package/dist/services/fileSnapshotStore.d.ts.map +1 -0
  44. package/dist/services/fileSnapshotStore.js +500 -0
  45. package/dist/services/instance-ai-config-service.d.ts +49 -0
  46. package/dist/services/instance-ai-config-service.d.ts.map +1 -0
  47. package/dist/services/instance-ai-config-service.js +174 -0
  48. package/dist/services/panel-auth.d.ts +8 -0
  49. package/dist/services/panel-auth.d.ts.map +1 -1
  50. package/dist/services/panel-auth.js +8 -0
  51. package/dist/services/ring-buffer.d.ts +67 -0
  52. package/dist/services/ring-buffer.d.ts.map +1 -0
  53. package/dist/services/ring-buffer.js +103 -0
  54. package/dist/services/session-output.d.ts +47 -3
  55. package/dist/services/session-output.d.ts.map +1 -1
  56. package/dist/services/session-output.js +112 -2
  57. package/dist/utils/instance-ai-config-debug-logger.d.ts +37 -0
  58. package/dist/utils/instance-ai-config-debug-logger.d.ts.map +1 -0
  59. package/dist/utils/instance-ai-config-debug-logger.js +63 -0
  60. package/dist/utils/logger.d.ts +18 -0
  61. package/dist/utils/logger.d.ts.map +1 -1
  62. package/dist/utils/logger.js +48 -4
  63. package/package/acode/dist/built-in-file-tools.d.ts +1 -1
  64. package/package/acode/dist/built-in-file-tools.d.ts.map +1 -1
  65. package/package/acode/dist/built-in-file-tools.js +5 -3
  66. package/package/acode/dist/builtins/commandArtifacts.d.ts +8 -1
  67. package/package/acode/dist/builtins/commandArtifacts.d.ts.map +1 -1
  68. package/package/acode/dist/builtins/commandArtifacts.js +24 -4
  69. package/package/acode/dist/builtins/shellCommandResult.d.ts +1 -0
  70. package/package/acode/dist/builtins/shellCommandResult.d.ts.map +1 -1
  71. package/package/acode/dist/builtins/shellCommandResult.js +3 -3
  72. package/package/acode/dist/builtins/shellCommandRunner.d.ts +1 -0
  73. package/package/acode/dist/builtins/shellCommandRunner.d.ts.map +1 -1
  74. package/package/acode/dist/builtins/shellCommandRunner.js +1 -0
  75. package/package/acode/dist/cli.js +2 -0
  76. package/package/acode/dist/runtime.d.ts.map +1 -1
  77. package/package/acode/dist/runtime.js +156 -5
  78. package/package/acode/dist/types.d.ts +1 -0
  79. package/package/acode/dist/types.d.ts.map +1 -1
  80. package/package/aws-client-agent-mcp/dist/agent-client.d.ts +5 -0
  81. package/package/aws-client-agent-mcp/dist/agent-client.d.ts.map +1 -1
  82. package/package/aws-client-agent-mcp/dist/agent-client.js +16 -0
  83. package/package/aws-client-agent-mcp/dist/agent-client.js.map +1 -1
  84. package/package/aws-client-agent-mcp/dist/context-manager.d.ts +136 -0
  85. package/package/aws-client-agent-mcp/dist/context-manager.d.ts.map +1 -0
  86. package/package/aws-client-agent-mcp/dist/context-manager.js +473 -0
  87. package/package/aws-client-agent-mcp/dist/context-manager.js.map +1 -0
  88. package/package/aws-client-agent-mcp/dist/context-manager.test.d.ts +6 -0
  89. package/package/aws-client-agent-mcp/dist/context-manager.test.d.ts.map +1 -0
  90. package/package/aws-client-agent-mcp/dist/context-manager.test.js +307 -0
  91. package/package/aws-client-agent-mcp/dist/context-manager.test.js.map +1 -0
  92. package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +170 -2
  93. package/package/aws-client-agent-mcp/dist/mcp-server.d.ts.map +1 -1
  94. package/package/aws-client-agent-mcp/dist/mcp-server.js +947 -9
  95. package/package/aws-client-agent-mcp/dist/mcp-server.js.map +1 -1
  96. package/package/aws-client-agent-mcp/dist/mcp-server.test.js +103 -1
  97. package/package/aws-client-agent-mcp/dist/mcp-server.test.js.map +1 -1
  98. package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +15 -1
  99. package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts.map +1 -1
  100. package/package/aws-client-agent-mcp/dist/mcp-tools.js +62 -2
  101. package/package/aws-client-agent-mcp/dist/mcp-tools.js.map +1 -1
  102. package/package/aws-client-agent-mcp/dist/memory-store.d.ts +46 -1
  103. package/package/aws-client-agent-mcp/dist/memory-store.d.ts.map +1 -1
  104. package/package/aws-client-agent-mcp/dist/memory-store.js +164 -12
  105. package/package/aws-client-agent-mcp/dist/memory-store.js.map +1 -1
  106. package/package/aws-client-agent-mcp/dist/memory-tools.d.ts +8 -0
  107. package/package/aws-client-agent-mcp/dist/memory-tools.d.ts.map +1 -1
  108. package/package/aws-client-agent-mcp/dist/memory-tools.js +88 -1
  109. package/package/aws-client-agent-mcp/dist/memory-tools.js.map +1 -1
  110. package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts +7 -1
  111. package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts.map +1 -1
  112. package/package/aws-client-agent-mcp/dist/server-memory-store.js +18 -0
  113. package/package/aws-client-agent-mcp/dist/server-memory-store.js.map +1 -1
  114. package/package/aws-client-agent-mcp/dist/types.d.ts +103 -2
  115. package/package/aws-client-agent-mcp/dist/types.d.ts.map +1 -1
  116. package/package/aws-client-agent-mcp/dist/types.js.map +1 -1
  117. package/package/aws-client-agent-mcp/dist/websocket-client.d.ts +27 -2
  118. package/package/aws-client-agent-mcp/dist/websocket-client.d.ts.map +1 -1
  119. package/package/aws-client-agent-mcp/dist/websocket-client.js +122 -5
  120. package/package/aws-client-agent-mcp/dist/websocket-client.js.map +1 -1
  121. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 事件推送 API 路由
3
+ *
4
+ * 提供事件推送相关的调试和管理端点。
5
+ */
6
+ export declare const eventsRouter: import("express-serve-static-core").Router;
7
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/routes/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,eAAO,MAAM,YAAY,4CAAW,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 事件推送 API 路由
3
+ *
4
+ * 提供事件推送相关的调试和管理端点。
5
+ */
6
+ import { Router } from "express";
7
+ import { validateToken } from "../middleware/auth.js";
8
+ import { getAllPushStats } from "../services/event-delta-pusher.js";
9
+ export const eventsRouter = Router();
10
+ /**
11
+ * GET /runtime/events/push-stats
12
+ *
13
+ * 返回每个 Agent 的待推送事件数、累计成功/失败、连续失败次数、最近延迟等。
14
+ */
15
+ eventsRouter.get("/events/push-stats", validateToken, (_req, res) => {
16
+ const stats = getAllPushStats();
17
+ res.json({
18
+ ok: true,
19
+ count: stats.length,
20
+ agents: stats,
21
+ });
22
+ });
@@ -41,7 +41,7 @@ export declare function createWorkspaceUploadLimitResponse(error: multer.MulterE
41
41
  };
42
42
  export declare function parseWorkspaceUploadRelativePaths(body: Record<string, unknown>): string[];
43
43
  /**
44
- * 主流程:从选中的工作目录生成受限目录树,最多 10 层且每个目录只返回前 20 个子目录。
44
+ * 主流程:从选中的工作目录生成目录树,根据 .gitignore 规则排除文件,不限制层数和项数。
45
45
  */
46
46
  export declare function listHostDirectoryTree(requestPath?: string): Promise<DirectoryTreeResponse>;
47
47
  export declare function parseGitIgnoreRules(content: string): GitIgnoreRule[];
@@ -1 +1 @@
1
- {"version":3,"file":"file-browser.d.ts","sourceRoot":"","sources":["../../src/routes/file-browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAyB5B,eAAO,MAAM,iBAAiB,4CAAW,CAAC;AAE1C,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAUhD,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,eA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AE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAWhH"}
@@ -23,8 +23,9 @@ const upload = multer({
23
23
  fileSize: 512 * 1024 * 1024
24
24
  }
25
25
  });
26
- const DIRECTORY_TREE_MAX_DEPTH = 10;
27
- const DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY = 20;
26
+ // 不限制层数和每层项数,仅根据 .gitignore 排除文件
27
+ const DIRECTORY_TREE_MAX_DEPTH = Number.MAX_SAFE_INTEGER;
28
+ const DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY = Number.MAX_SAFE_INTEGER;
28
29
  function toBoolean(value) {
29
30
  return value === true || value === 'true' || value === '1';
30
31
  }
@@ -144,7 +145,7 @@ async function listHostDirectories(requestPath = '') {
144
145
  };
145
146
  }
146
147
  /**
147
- * 主流程:从选中的工作目录生成受限目录树,最多 10 层且每个目录只返回前 20 个子目录。
148
+ * 主流程:从选中的工作目录生成目录树,根据 .gitignore 规则排除文件,不限制层数和项数。
148
149
  */
149
150
  export async function listHostDirectoryTree(requestPath = '') {
150
151
  const root = await listHostDirectories(requestPath);
@@ -222,13 +223,28 @@ export function parseGitIgnoreRules(content) {
222
223
  .filter((rule) => rule.pattern.length > 0);
223
224
  }
224
225
  async function loadGitIgnoreRules(rootPath) {
225
- try {
226
- const content = await fs.readFile(path.join(rootPath, '.gitignore'), 'utf8');
227
- return parseGitIgnoreRules(content);
228
- }
229
- catch {
230
- return [];
226
+ const allRules = [];
227
+ let currentPath = rootPath;
228
+ // 向上遍历目录树,收集所有 .gitignore 文件
229
+ while (true) {
230
+ try {
231
+ const gitignorePath = path.join(currentPath, '.gitignore');
232
+ const content = await fs.readFile(gitignorePath, 'utf8');
233
+ const rules = parseGitIgnoreRules(content);
234
+ // 将新规则插入到前面,因为上层目录的规则优先级更高
235
+ allRules.unshift(...rules);
236
+ }
237
+ catch {
238
+ // 没有 .gitignore 文件,继续向上查找
239
+ }
240
+ // 到达根目录则停止
241
+ const parentPath = path.dirname(currentPath);
242
+ if (parentPath === currentPath) {
243
+ break;
244
+ }
245
+ currentPath = parentPath;
231
246
  }
247
+ return allRules;
232
248
  }
233
249
  export function isIgnoredByGitIgnore(relativePath, isDirectory, rules) {
234
250
  const normalizedPath = normalizeRelativePath(relativePath);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 文件快照 API 路由
3
+ *
4
+ * 提供基于文件内容哈希的确定性快照,替代 git stash 实现稳定可靠的快照与还原。
5
+ * - 创建快照:遍历工作区,整文件备份 + 内容哈希去重
6
+ * - 还原快照:先清后写,整文件覆盖,零冲突,幂等
7
+ * - 列表/删除:按快照 key 管理生命周期
8
+ */
9
+ export declare const fileSnapshotRouter: import("express-serve-static-core").Router;
10
+ //# sourceMappingURL=file-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-snapshot.d.ts","sourceRoot":"","sources":["../../src/routes/file-snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,eAAO,MAAM,kBAAkB,4CAAW,CAAC"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * 文件快照 API 路由
3
+ *
4
+ * 提供基于文件内容哈希的确定性快照,替代 git stash 实现稳定可靠的快照与还原。
5
+ * - 创建快照:遍历工作区,整文件备份 + 内容哈希去重
6
+ * - 还原快照:先清后写,整文件覆盖,零冲突,幂等
7
+ * - 列表/删除:按快照 key 管理生命周期
8
+ */
9
+ import { Router } from "express";
10
+ import { validateToken } from "../middleware/auth.js";
11
+ import { createLogger } from "../utils/logger.js";
12
+ import { createSnapshot, restoreSnapshot, listSnapshots, deleteSnapshot, getSnapshotRootPath, } from "../services/fileSnapshotStore.js";
13
+ export const fileSnapshotRouter = Router();
14
+ const log = createLogger("file-snapshot");
15
+ /**
16
+ * 创建文件快照
17
+ * POST /runtime/file-snapshot/create
18
+ */
19
+ fileSnapshotRouter.post("/file-snapshot/create", validateToken, async (req, res) => {
20
+ const { workspacePath, snapshotId, snapshotName, triggerType } = req.body || {};
21
+ if (!workspacePath || !String(workspacePath).trim()) {
22
+ res.status(400).json({ error: "workspacePath is required" });
23
+ return;
24
+ }
25
+ try {
26
+ const result = await createSnapshot({
27
+ workspacePath: String(workspacePath).trim(),
28
+ snapshotId: snapshotId ? String(snapshotId).trim() : undefined,
29
+ snapshotName: snapshotName ? String(snapshotName).trim() : undefined,
30
+ triggerType: triggerType ? String(triggerType).trim() : undefined,
31
+ });
32
+ if (!result.ok) {
33
+ log.warn(`[FileSnapshot] 创建快照失败: ${result.error}`);
34
+ res.status(500).json({ ok: false, error: result.error });
35
+ return;
36
+ }
37
+ res.json({
38
+ ok: true,
39
+ snapshotId: result.snapshotId,
40
+ snapshotKey: result.snapshotKey,
41
+ fileCount: result.fileCount,
42
+ totalBytes: result.totalBytes,
43
+ workspaceHash: result.workspaceHash,
44
+ workspacePath: String(workspacePath).trim(),
45
+ });
46
+ }
47
+ catch (error) {
48
+ const err = error;
49
+ log.error(`[FileSnapshot] 创建快照异常: ${err.message}`);
50
+ res.status(500).json({ ok: false, error: err.message || "create snapshot failed" });
51
+ }
52
+ });
53
+ /**
54
+ * 还原文件快照
55
+ * POST /runtime/file-snapshot/restore
56
+ */
57
+ fileSnapshotRouter.post("/file-snapshot/restore", validateToken, async (req, res) => {
58
+ const { workspacePath, snapshotKey, preRestoreBackup } = req.body || {};
59
+ if (!workspacePath || !String(workspacePath).trim()) {
60
+ res.status(400).json({ error: "workspacePath is required" });
61
+ return;
62
+ }
63
+ if (!snapshotKey || !String(snapshotKey).trim()) {
64
+ res.status(400).json({ error: "snapshotKey is required" });
65
+ return;
66
+ }
67
+ try {
68
+ const result = await restoreSnapshot({
69
+ workspacePath: String(workspacePath).trim(),
70
+ snapshotKey: String(snapshotKey).trim(),
71
+ preRestoreBackup: preRestoreBackup !== false,
72
+ });
73
+ if (!result.ok) {
74
+ log.warn(`[FileSnapshot] 还原快照失败: ${result.error}`);
75
+ res.status(500).json({ ok: false, error: result.error });
76
+ return;
77
+ }
78
+ res.json({
79
+ ok: true,
80
+ filesRestored: result.filesRestored,
81
+ filesDeleted: result.filesDeleted,
82
+ filesSkipped: result.filesSkipped,
83
+ preRestoreSnapshotKey: result.preRestoreSnapshotKey || null,
84
+ workspacePath: String(workspacePath).trim(),
85
+ });
86
+ }
87
+ catch (error) {
88
+ const err = error;
89
+ log.error(`[FileSnapshot] 还原快照异常: ${err.message}`);
90
+ res.status(500).json({ ok: false, error: err.message || "restore snapshot failed" });
91
+ }
92
+ });
93
+ /**
94
+ * 列出快照
95
+ * POST /runtime/file-snapshot/list
96
+ */
97
+ fileSnapshotRouter.post("/file-snapshot/list", validateToken, async (req, res) => {
98
+ const { workspacePath } = req.body || {};
99
+ if (!workspacePath || !String(workspacePath).trim()) {
100
+ res.status(400).json({ error: "workspacePath is required" });
101
+ return;
102
+ }
103
+ try {
104
+ const snapshots = await listSnapshots(String(workspacePath).trim());
105
+ res.json({
106
+ ok: true,
107
+ snapshots,
108
+ count: snapshots.length,
109
+ workspacePath: String(workspacePath).trim(),
110
+ });
111
+ }
112
+ catch (error) {
113
+ const err = error;
114
+ log.error(`[FileSnapshot] 列出快照异常: ${err.message}`);
115
+ res.status(500).json({ ok: false, error: err.message || "list snapshots failed" });
116
+ }
117
+ });
118
+ /**
119
+ * 删除快照
120
+ * POST /runtime/file-snapshot/delete
121
+ */
122
+ fileSnapshotRouter.post("/file-snapshot/delete", validateToken, async (req, res) => {
123
+ const { snapshotKey } = req.body || {};
124
+ if (!snapshotKey || !String(snapshotKey).trim()) {
125
+ res.status(400).json({ error: "snapshotKey is required" });
126
+ return;
127
+ }
128
+ try {
129
+ const result = await deleteSnapshot(String(snapshotKey).trim());
130
+ if (!result.ok) {
131
+ log.warn(`[FileSnapshot] 删除快照失败: ${result.error}`);
132
+ res.status(result.error?.includes("not found") ? 404 : 500).json({ ok: false, error: result.error });
133
+ return;
134
+ }
135
+ res.json({
136
+ ok: true,
137
+ snapshotKey: String(snapshotKey).trim(),
138
+ message: `已删除快照 ${snapshotKey}`,
139
+ });
140
+ }
141
+ catch (error) {
142
+ const err = error;
143
+ log.error(`[FileSnapshot] 删除快照异常: ${err.message}`);
144
+ res.status(500).json({ ok: false, error: err.message || "delete snapshot failed" });
145
+ }
146
+ });
147
+ /**
148
+ * 快照存储诊断信息
149
+ * POST /runtime/file-snapshot/info
150
+ */
151
+ fileSnapshotRouter.post("/file-snapshot/info", validateToken, async (_req, res) => {
152
+ res.json({
153
+ ok: true,
154
+ snapshotRoot: getSnapshotRootPath(),
155
+ });
156
+ });
@@ -82,6 +82,11 @@ export declare function parseGitStatusStagedPaths(output: string): Set<string>;
82
82
  * 解析 git diff 的 name-status 与 numstat 输出,生成前端文件树需要的汇总数据。
83
83
  */
84
84
  export declare function parseGitDiffSummary(nameStatusOutput: string, numstatOutput: string, stagedPaths?: Set<string>, forceStaged?: boolean): GitDiffSummaryFile[];
85
+ /**
86
+ * 从 git status --porcelain 输出中提取未跟踪 (untracked) 路径。
87
+ * `??` 前缀表示未跟踪文件或目录。
88
+ */
89
+ export declare function parseGitStatusUntrackedPaths(output: string): string[];
85
90
  /**
86
91
  * 合并工作区与暂存区差异汇总。
87
92
  * 主流程:以路径去重,保留工作区展示顺序;同一路径若也存在暂存变更则标记为 staged 并累加统计。
@@ -90,5 +95,10 @@ export declare function mergeGitDiffSummaryFiles(unstagedFiles: GitDiffSummaryFi
90
95
  export declare function normalizeGitCommitMessage(message: unknown): string;
91
96
  export declare function createScopedGitPathspecArgs(context: Pick<GitRepositoryContext, 'relativeWorkspacePath'>): string[];
92
97
  export declare function createScopedFilePathspecArgs(filePath: string, context: Pick<GitRepositoryContext, 'relativeWorkspacePath'>): string[];
98
+ /**
99
+ * 调用 OpenAI-compatible API 生成 Git 提交信息。
100
+ * 具体功能:将暂存区 diff 作为上下文发送给 AI,返回生成的提交信息文本。
101
+ */
102
+ export declare function callAiForCommitMessage(aiBaseUrl: string, aiApiKey: string, aiModel: string, diffContent: string): Promise<string>;
93
103
  export {};
94
104
  //# sourceMappingURL=git.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/routes/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,eAAO,MAAM,SAAS,4CAAW,CAAC;AAIlC;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAOnD;AAED,UAAU,oBAAoB;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAsB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe3F;AAED,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,KAAK,iBAAiB,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAItE,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAUD;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,OAAO,GACpB,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAK3E;AAED,wBAA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