@ipul-labs/forge 1.22.0 → 1.35.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.
- package/LICENSE +21 -0
- package/README.md +153 -78
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/index-BmEuPeOG.js +27 -0
- package/dist/assets/index-CSH1OQYQ.css +1 -0
- package/dist/boot-check.js +98 -0
- package/dist/favicon.svg +8 -0
- package/dist/icon-192.png +0 -0
- package/dist/icon-512.png +0 -0
- package/dist/icon.svg +12 -0
- package/dist/index.html +33 -0
- package/dist/manifest.webmanifest +18 -0
- package/dist/theme-init.js +11 -0
- package/lib/bin/cli/analyze.d.ts.map +1 -1
- package/lib/bin/cli/analyze.js +3 -44
- package/lib/bin/cli/analyze.js.map +1 -1
- package/lib/bin/cli/apply.d.ts.map +1 -1
- package/lib/bin/cli/apply.js +2 -20
- package/lib/bin/cli/apply.js.map +1 -1
- package/lib/bin/cli/cifix.d.ts.map +1 -1
- package/lib/bin/cli/cifix.js +4 -28
- package/lib/bin/cli/cifix.js.map +1 -1
- package/lib/bin/cli/close.d.ts.map +1 -1
- package/lib/bin/cli/close.js +2 -33
- package/lib/bin/cli/close.js.map +1 -1
- package/lib/bin/cli/createIssue.d.ts.map +1 -1
- package/lib/bin/cli/createIssue.js +3 -12
- package/lib/bin/cli/createIssue.js.map +1 -1
- package/lib/bin/cli/doctor.d.ts.map +1 -1
- package/lib/bin/cli/doctor.js +3 -4
- package/lib/bin/cli/doctor.js.map +1 -1
- package/lib/bin/cli/init.js +1 -10
- package/lib/bin/cli/init.js.map +1 -1
- package/lib/bin/cli/issue.d.ts.map +1 -1
- package/lib/bin/cli/issue.js +3 -12
- package/lib/bin/cli/issue.js.map +1 -1
- package/lib/bin/cli/issues.d.ts.map +1 -1
- package/lib/bin/cli/issues.js +3 -12
- package/lib/bin/cli/issues.js.map +1 -1
- package/lib/bin/cli/merge.d.ts.map +1 -1
- package/lib/bin/cli/merge.js +4 -20
- package/lib/bin/cli/merge.js.map +1 -1
- package/lib/bin/cli/refine.d.ts.map +1 -1
- package/lib/bin/cli/refine.js +2 -26
- package/lib/bin/cli/refine.js.map +1 -1
- package/lib/bin/cli/repl.d.ts.map +1 -1
- package/lib/bin/cli/repl.js +4 -13
- package/lib/bin/cli/repl.js.map +1 -1
- package/lib/bin/cli/repos.d.ts.map +1 -1
- package/lib/bin/cli/repos.js +1 -11
- package/lib/bin/cli/repos.js.map +1 -1
- package/lib/bin/cli/resetPassword.d.ts +21 -0
- package/lib/bin/cli/resetPassword.d.ts.map +1 -0
- package/lib/bin/cli/resetPassword.js +69 -0
- package/lib/bin/cli/resetPassword.js.map +1 -0
- package/lib/bin/cli/resolution.d.ts.map +1 -1
- package/lib/bin/cli/resolution.js +2 -19
- package/lib/bin/cli/resolution.js.map +1 -1
- package/lib/bin/cli/serverClient.d.ts +2 -0
- package/lib/bin/cli/serverClient.d.ts.map +1 -1
- package/lib/bin/cli/serverClient.js +8 -4
- package/lib/bin/cli/serverClient.js.map +1 -1
- package/lib/bin/cli/session.d.ts.map +1 -1
- package/lib/bin/cli/session.js.map +1 -1
- package/lib/bin/cli/sessionStore.d.ts +1 -1
- package/lib/bin/cli/sessionStore.js +2 -2
- package/lib/bin/cli/sessionStore.js.map +1 -1
- package/lib/bin/cli/ship.d.ts.map +1 -1
- package/lib/bin/cli/ship.js +15 -23
- package/lib/bin/cli/ship.js.map +1 -1
- package/lib/bin/cli/update.d.ts.map +1 -1
- package/lib/bin/cli/update.js +34 -28
- package/lib/bin/cli/update.js.map +1 -1
- package/lib/bin/cli/updatePlan.d.ts +30 -0
- package/lib/bin/cli/updatePlan.d.ts.map +1 -0
- package/lib/bin/cli/updatePlan.js +50 -0
- package/lib/bin/cli/updatePlan.js.map +1 -0
- package/lib/bin/cli/utils.d.ts +3 -0
- package/lib/bin/cli/utils.d.ts.map +1 -1
- package/lib/bin/cli/utils.js +7 -23
- package/lib/bin/cli/utils.js.map +1 -1
- package/lib/bin/cli/validate.d.ts.map +1 -1
- package/lib/bin/cli/validate.js +3 -25
- package/lib/bin/cli/validate.js.map +1 -1
- package/lib/bin/cli/watch.d.ts.map +1 -1
- package/lib/bin/cli/watch.js +3 -12
- package/lib/bin/cli/watch.js.map +1 -1
- package/lib/bin/forge-agent.js +10 -22
- package/lib/bin/forge-agent.js.map +1 -1
- package/lib/server/app.d.ts +24 -0
- package/lib/server/app.d.ts.map +1 -0
- package/lib/server/app.js +58 -0
- package/lib/server/app.js.map +1 -0
- package/lib/server/forge/analyses/analysisStore.d.ts +53 -0
- package/lib/server/forge/analyses/analysisStore.d.ts.map +1 -0
- package/lib/server/forge/analyses/analysisStore.js +77 -0
- package/lib/server/forge/analyses/analysisStore.js.map +1 -0
- package/lib/server/forge/auth/apiTokens.d.ts +34 -0
- package/lib/server/forge/auth/apiTokens.d.ts.map +1 -0
- package/lib/server/forge/auth/apiTokens.js +44 -0
- package/lib/server/forge/auth/apiTokens.js.map +1 -0
- package/lib/server/forge/auth/auditLog.d.ts +36 -0
- package/lib/server/forge/auth/auditLog.d.ts.map +1 -0
- package/lib/server/forge/auth/auditLog.js +56 -0
- package/lib/server/forge/auth/auditLog.js.map +1 -0
- package/lib/server/forge/auth/authConfig.d.ts +13 -0
- package/lib/server/forge/auth/authConfig.d.ts.map +1 -0
- package/lib/server/forge/auth/authConfig.js +37 -0
- package/lib/server/forge/auth/authConfig.js.map +1 -0
- package/lib/server/forge/auth/createAuth.d.ts +130 -0
- package/lib/server/forge/auth/createAuth.d.ts.map +1 -0
- package/lib/server/forge/auth/createAuth.js +387 -0
- package/lib/server/forge/auth/createAuth.js.map +1 -0
- package/lib/server/forge/auth/middleware.d.ts +10 -0
- package/lib/server/forge/auth/middleware.d.ts.map +1 -0
- package/lib/server/forge/auth/middleware.js +22 -0
- package/lib/server/forge/auth/middleware.js.map +1 -0
- package/lib/server/forge/auth/oidc.d.ts +38 -0
- package/lib/server/forge/auth/oidc.d.ts.map +1 -0
- package/lib/server/forge/auth/oidc.js +63 -0
- package/lib/server/forge/auth/oidc.js.map +1 -0
- package/lib/server/forge/auth/passwords.d.ts +7 -0
- package/lib/server/forge/auth/passwords.d.ts.map +1 -0
- package/lib/server/forge/auth/passwords.js +28 -0
- package/lib/server/forge/auth/passwords.js.map +1 -0
- package/lib/server/forge/auth/resetPassword.d.ts +14 -0
- package/lib/server/forge/auth/resetPassword.d.ts.map +1 -0
- package/lib/server/forge/auth/resetPassword.js +29 -0
- package/lib/server/forge/auth/resetPassword.js.map +1 -0
- package/lib/server/forge/auth/roles.d.ts +7 -0
- package/lib/server/forge/auth/roles.d.ts.map +1 -0
- package/lib/server/forge/auth/roles.js +15 -0
- package/lib/server/forge/auth/roles.js.map +1 -0
- package/lib/server/forge/auth/sessions.d.ts +27 -0
- package/lib/server/forge/auth/sessions.d.ts.map +1 -0
- package/lib/server/forge/auth/sessions.js +37 -0
- package/lib/server/forge/auth/sessions.js.map +1 -0
- package/lib/server/forge/auth/testHarness.d.ts +104 -0
- package/lib/server/forge/auth/testHarness.d.ts.map +1 -0
- package/lib/server/forge/auth/testHarness.js +53 -0
- package/lib/server/forge/auth/testHarness.js.map +1 -0
- package/lib/server/forge/auth/tokenHash.d.ts +3 -0
- package/lib/server/forge/auth/tokenHash.d.ts.map +1 -0
- package/lib/server/forge/auth/tokenHash.js +4 -0
- package/lib/server/forge/auth/tokenHash.js.map +1 -0
- package/lib/server/forge/auth/users.d.ts +51 -0
- package/lib/server/forge/auth/users.d.ts.map +1 -0
- package/lib/server/forge/auth/users.js +118 -0
- package/lib/server/forge/auth/users.js.map +1 -0
- package/lib/server/forge/core/ForgeAgent.d.ts +43 -1
- package/lib/server/forge/core/ForgeAgent.d.ts.map +1 -1
- package/lib/server/forge/core/ForgeAgent.js +209 -61
- package/lib/server/forge/core/ForgeAgent.js.map +1 -1
- package/lib/server/forge/core/agentClient.d.ts +7 -23
- package/lib/server/forge/core/agentClient.d.ts.map +1 -1
- package/lib/server/forge/core/agentClient.js +10 -25
- package/lib/server/forge/core/agentClient.js.map +1 -1
- package/lib/server/forge/core/claudeClient.d.ts +24 -1
- package/lib/server/forge/core/claudeClient.d.ts.map +1 -1
- package/lib/server/forge/core/claudeClient.js +25 -7
- package/lib/server/forge/core/claudeClient.js.map +1 -1
- package/lib/server/forge/core/configStore.d.ts +11 -1
- package/lib/server/forge/core/configStore.d.ts.map +1 -1
- package/lib/server/forge/core/configStore.js +33 -2
- package/lib/server/forge/core/configStore.js.map +1 -1
- package/lib/server/forge/core/dependencyPaths.d.ts +19 -0
- package/lib/server/forge/core/dependencyPaths.d.ts.map +1 -0
- package/lib/server/forge/core/dependencyPaths.js +32 -0
- package/lib/server/forge/core/dependencyPaths.js.map +1 -0
- package/lib/server/forge/core/evidence.d.ts +43 -0
- package/lib/server/forge/core/evidence.d.ts.map +1 -0
- package/lib/server/forge/core/evidence.js +108 -0
- package/lib/server/forge/core/evidence.js.map +1 -0
- package/lib/server/forge/core/jobs.d.ts +2 -0
- package/lib/server/forge/core/jobs.d.ts.map +1 -1
- package/lib/server/forge/core/jobs.js +8 -0
- package/lib/server/forge/core/jobs.js.map +1 -1
- package/lib/server/forge/core/localRepo.d.ts +31 -10
- package/lib/server/forge/core/localRepo.d.ts.map +1 -1
- package/lib/server/forge/core/localRepo.js +48 -82
- package/lib/server/forge/core/localRepo.js.map +1 -1
- package/lib/server/forge/core/prompts.d.ts +3 -1
- package/lib/server/forge/core/prompts.d.ts.map +1 -1
- package/lib/server/forge/core/prompts.js +14 -5
- package/lib/server/forge/core/prompts.js.map +1 -1
- package/lib/server/forge/core/providers/azuredevops.d.ts +4 -2
- package/lib/server/forge/core/providers/azuredevops.d.ts.map +1 -1
- package/lib/server/forge/core/providers/azuredevops.js +12 -2
- package/lib/server/forge/core/providers/azuredevops.js.map +1 -1
- package/lib/server/forge/core/providers/base.d.ts +29 -4
- package/lib/server/forge/core/providers/base.d.ts.map +1 -1
- package/lib/server/forge/core/providers/base.js +21 -3
- package/lib/server/forge/core/providers/base.js.map +1 -1
- package/lib/server/forge/core/providers/github.d.ts +7 -7
- package/lib/server/forge/core/providers/github.d.ts.map +1 -1
- package/lib/server/forge/core/providers/github.js +13 -4
- package/lib/server/forge/core/providers/github.js.map +1 -1
- package/lib/server/forge/core/providers/gitlab.d.ts +20 -3
- package/lib/server/forge/core/providers/gitlab.d.ts.map +1 -1
- package/lib/server/forge/core/providers/gitlab.js +65 -5
- package/lib/server/forge/core/providers/gitlab.js.map +1 -1
- package/lib/server/forge/core/providers/types.d.ts +20 -0
- package/lib/server/forge/core/providers/types.d.ts.map +1 -1
- package/lib/server/forge/core/secretBox.d.ts +17 -0
- package/lib/server/forge/core/secretBox.d.ts.map +1 -0
- package/lib/server/forge/core/secretBox.js +74 -0
- package/lib/server/forge/core/secretBox.js.map +1 -0
- package/lib/server/forge/core/types.d.ts +7 -1
- package/lib/server/forge/core/types.d.ts.map +1 -1
- package/lib/server/forge/core/validator/clone.d.ts +5 -4
- package/lib/server/forge/core/validator/clone.d.ts.map +1 -1
- package/lib/server/forge/core/validator/clone.js +6 -86
- package/lib/server/forge/core/validator/clone.js.map +1 -1
- package/lib/server/forge/core/validator/cmd.d.ts.map +1 -1
- package/lib/server/forge/core/validator/cmd.js +4 -1
- package/lib/server/forge/core/validator/cmd.js.map +1 -1
- package/lib/server/forge/core/validator/projectType.d.ts.map +1 -1
- package/lib/server/forge/core/validator/projectType.js +2 -1
- package/lib/server/forge/core/validator/projectType.js.map +1 -1
- package/lib/server/forge/core/validator/runners/node.d.ts.map +1 -1
- package/lib/server/forge/core/validator/runners/node.js +6 -2
- package/lib/server/forge/core/validator/runners/node.js.map +1 -1
- package/lib/server/forge/core/validator.d.ts.map +1 -1
- package/lib/server/forge/core/validator.js +28 -22
- package/lib/server/forge/core/validator.js.map +1 -1
- package/lib/server/forge/core/workspaces.d.ts +70 -0
- package/lib/server/forge/core/workspaces.d.ts.map +1 -0
- package/lib/server/forge/core/workspaces.js +348 -0
- package/lib/server/forge/core/workspaces.js.map +1 -0
- package/lib/server/forge/db/database.d.ts +22 -0
- package/lib/server/forge/db/database.d.ts.map +1 -0
- package/lib/server/forge/db/database.js +71 -0
- package/lib/server/forge/db/database.js.map +1 -0
- package/lib/server/forge/db/migrations.d.ts +11 -0
- package/lib/server/forge/db/migrations.d.ts.map +1 -0
- package/lib/server/forge/db/migrations.js +87 -0
- package/lib/server/forge/db/migrations.js.map +1 -0
- package/lib/server/forge/routes.d.ts.map +1 -1
- package/lib/server/forge/routes.js +413 -163
- package/lib/server/forge/routes.js.map +1 -1
- package/lib/server/forge/sse.d.ts +10 -0
- package/lib/server/forge/sse.d.ts.map +1 -0
- package/lib/server/forge/sse.js +22 -0
- package/lib/server/forge/sse.js.map +1 -0
- package/lib/server/spa.d.ts +12 -0
- package/lib/server/spa.d.ts.map +1 -0
- package/lib/server/spa.js +23 -0
- package/lib/server/spa.js.map +1 -0
- package/lib/server.js +9 -24
- package/lib/server.js.map +1 -1
- package/lib/shared/events.d.ts +3 -0
- package/lib/shared/events.d.ts.map +1 -1
- package/lib/shared/events.js +3 -0
- package/lib/shared/events.js.map +1 -1
- package/lib/shared/packageRoot.d.ts +11 -0
- package/lib/shared/packageRoot.d.ts.map +1 -0
- package/lib/shared/packageRoot.js +23 -0
- package/lib/shared/packageRoot.js.map +1 -0
- package/lib/shared/project.d.ts +3 -0
- package/lib/shared/project.d.ts.map +1 -0
- package/lib/shared/project.js +3 -0
- package/lib/shared/project.js.map +1 -0
- package/package.json +24 -9
- package/lib/bin/cli/improve.d.ts +0 -2
- package/lib/bin/cli/improve.d.ts.map +0 -1
- package/lib/bin/cli/improve.js +0 -189
- package/lib/bin/cli/improve.js.map +0 -1
- package/lib/bin/cli/stats.d.ts +0 -2
- package/lib/bin/cli/stats.d.ts.map +0 -1
- package/lib/bin/cli/stats.js +0 -78
- package/lib/bin/cli/stats.js.map +0 -1
- package/lib/server/forge/core/k8s.d.ts +0 -18
- package/lib/server/forge/core/k8s.d.ts.map +0 -1
- package/lib/server/forge/core/k8s.js +0 -49
- package/lib/server/forge/core/k8s.js.map +0 -1
- package/lib/server/forge/core/openclawClient.d.ts +0 -61
- package/lib/server/forge/core/openclawClient.d.ts.map +0 -1
- package/lib/server/forge/core/openclawClient.js +0 -111
- package/lib/server/forge/core/openclawClient.js.map +0 -1
- package/lib/server/forge/core/quotaClient.d.ts +0 -48
- package/lib/server/forge/core/quotaClient.d.ts.map +0 -1
- package/lib/server/forge/core/quotaClient.js +0 -88
- package/lib/server/forge/core/quotaClient.js.map +0 -1
- package/lib/server/forge/core/selfImprove.d.ts +0 -43
- package/lib/server/forge/core/selfImprove.d.ts.map +0 -1
- package/lib/server/forge/core/selfImprove.js +0 -372
- package/lib/server/forge/core/selfImprove.js.map +0 -1
- package/lib/server/forge/core/telemetry.d.ts +0 -100
- package/lib/server/forge/core/telemetry.d.ts.map +0 -1
- package/lib/server/forge/core/telemetry.js +0 -273
- package/lib/server/forge/core/telemetry.js.map +0 -1
- package/scripts/fix-shebang.cjs +0 -11
- package/scripts/inject-readme.cjs +0 -23
- package/scripts/local-rollout.sh +0 -134
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/forge/core/openclawClient.js
|
|
3
|
-
*
|
|
4
|
-
* Communicates with a locally-running OpenClaw Gateway over HTTP.
|
|
5
|
-
* Configure with:
|
|
6
|
-
* OPENCLAW_GATEWAY_URL — e.g. http://192.168.x.x:18789 (Tailscale) or SSH tunnel
|
|
7
|
-
* OPENCLAW_TOKEN — Bearer token if your Gateway requires auth
|
|
8
|
-
*
|
|
9
|
-
* The Gateway runs on 127.0.0.1:18789 by default. Expose it remotely via:
|
|
10
|
-
* Tailscale: bind to tailnet interface
|
|
11
|
-
* SSH tunnel: ssh -N -L 18789:127.0.0.1:18789 user@host
|
|
12
|
-
*/
|
|
13
|
-
import type { NormalDiff } from "./providers/types.ts";
|
|
14
|
-
import type { AgentResponse, ForgeChange, ForgeEvent } from "./types.ts";
|
|
15
|
-
interface IssueInput {
|
|
16
|
-
iid?: number;
|
|
17
|
-
title?: string | null;
|
|
18
|
-
description?: string | null;
|
|
19
|
-
labels?: Array<string | {
|
|
20
|
-
name?: string;
|
|
21
|
-
}> | null;
|
|
22
|
-
}
|
|
23
|
-
interface FileContent {
|
|
24
|
-
repo?: string;
|
|
25
|
-
path: string;
|
|
26
|
-
content: string;
|
|
27
|
-
}
|
|
28
|
-
interface RepoTree {
|
|
29
|
-
repo: string;
|
|
30
|
-
files: string[];
|
|
31
|
-
}
|
|
32
|
-
interface ProposeFixOptions {
|
|
33
|
-
feedback?: string;
|
|
34
|
-
ciContext?: string;
|
|
35
|
-
userPrompt?: string;
|
|
36
|
-
repos?: string[];
|
|
37
|
-
promptRules?: string;
|
|
38
|
-
previousChanges?: ForgeChange[];
|
|
39
|
-
}
|
|
40
|
-
interface RefineOptions {
|
|
41
|
-
feedback?: string;
|
|
42
|
-
previousChanges?: ForgeChange[];
|
|
43
|
-
validationState?: unknown;
|
|
44
|
-
repos?: string[];
|
|
45
|
-
repoTrees?: RepoTree[];
|
|
46
|
-
repoAccessMode?: string;
|
|
47
|
-
promptRules?: string;
|
|
48
|
-
repoCwd?: string;
|
|
49
|
-
sessionId?: string;
|
|
50
|
-
resumeSession?: boolean;
|
|
51
|
-
}
|
|
52
|
-
interface GatewayCallOpts {
|
|
53
|
-
signal?: AbortSignal;
|
|
54
|
-
timeout?: number;
|
|
55
|
-
}
|
|
56
|
-
export declare function checkResolution(issue: IssueInput, diffs: NormalDiff[], model: string | undefined, opts?: GatewayCallOpts): Promise<AgentResponse>;
|
|
57
|
-
export declare function identifyRelevantFiles(issue: IssueInput, fileTree: RepoTree[] | string[], model: string | undefined, opts?: GatewayCallOpts): Promise<AgentResponse>;
|
|
58
|
-
export declare function proposeFix(issue: IssueInput, fileContents: FileContent[], options: ProposeFixOptions, model: string | undefined, opts?: GatewayCallOpts): Promise<AgentResponse>;
|
|
59
|
-
export declare function refineOrAsk(issue: IssueInput, fileContents: FileContent[], options: RefineOptions, model: string | undefined, _onEvent: ((evt: ForgeEvent) => void) | undefined, opts?: GatewayCallOpts): Promise<AgentResponse>;
|
|
60
|
-
export {};
|
|
61
|
-
//# sourceMappingURL=openclawClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclawClient.d.ts","sourceRoot":"","sources":["../../../../server/forge/core/openclawClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzE,UAAU,UAAU;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CAClD;AAED,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,UAAU,iBAAiB;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC;CAChC;AAED,UAAU,aAAa;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,WAAW,EA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,CAAC,aAAa,CAAC,CAM/O"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/forge/core/openclawClient.js
|
|
3
|
-
*
|
|
4
|
-
* Communicates with a locally-running OpenClaw Gateway over HTTP.
|
|
5
|
-
* Configure with:
|
|
6
|
-
* OPENCLAW_GATEWAY_URL — e.g. http://192.168.x.x:18789 (Tailscale) or SSH tunnel
|
|
7
|
-
* OPENCLAW_TOKEN — Bearer token if your Gateway requires auth
|
|
8
|
-
*
|
|
9
|
-
* The Gateway runs on 127.0.0.1:18789 by default. Expose it remotely via:
|
|
10
|
-
* Tailscale: bind to tailnet interface
|
|
11
|
-
* SSH tunnel: ssh -N -L 18789:127.0.0.1:18789 user@host
|
|
12
|
-
*/
|
|
13
|
-
import { buildIdentifyFilesPrompt, buildProposeFixPrompt, buildRefineOrAskPrompt, buildCheckResolutionPrompt, } from "./prompts.js";
|
|
14
|
-
const GATEWAY_URL = process.env.OPENCLAW_GATEWAY_URL?.replace(/\/$/, "");
|
|
15
|
-
const GATEWAY_TOKEN = process.env.OPENCLAW_TOKEN;
|
|
16
|
-
const TIMEOUT_MS = 120_000;
|
|
17
|
-
// ─── JSON output helpers ──────────────────────────────────────────────────────
|
|
18
|
-
function extractJSON(text) {
|
|
19
|
-
const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
20
|
-
if (fenced)
|
|
21
|
-
return JSON.parse(fenced[1].trim());
|
|
22
|
-
const start = text.indexOf("{");
|
|
23
|
-
const end = text.lastIndexOf("}");
|
|
24
|
-
if (start !== -1 && end !== -1)
|
|
25
|
-
return JSON.parse(text.slice(start, end + 1));
|
|
26
|
-
throw new Error("No JSON found in OpenClaw response");
|
|
27
|
-
}
|
|
28
|
-
// ─── Gateway transport ────────────────────────────────────────────────────────
|
|
29
|
-
/**
|
|
30
|
-
* Send a prompt to the OpenClaw Gateway and return the text response.
|
|
31
|
-
*
|
|
32
|
-
* @param {string} prompt
|
|
33
|
-
* @param {string} [model]
|
|
34
|
-
* @param {{ signal?: AbortSignal }} [opts]
|
|
35
|
-
* @returns {Promise<string>}
|
|
36
|
-
*/
|
|
37
|
-
async function callGateway(prompt, model, opts = {}) {
|
|
38
|
-
if (!GATEWAY_URL) {
|
|
39
|
-
throw new Error("OPENCLAW_GATEWAY_URL is not set. Add it to your .env and point it at your OpenClaw Gateway.");
|
|
40
|
-
}
|
|
41
|
-
const controller = new AbortController();
|
|
42
|
-
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
43
|
-
// Chain the external cancel signal so a job cancel aborts the fetch in
|
|
44
|
-
// addition to the timeout.
|
|
45
|
-
const external = opts.signal;
|
|
46
|
-
const onExternalAbort = () => controller.abort();
|
|
47
|
-
if (external) {
|
|
48
|
-
if (external.aborted)
|
|
49
|
-
controller.abort();
|
|
50
|
-
else
|
|
51
|
-
external.addEventListener("abort", onExternalAbort, { once: true });
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const body = { message: prompt };
|
|
55
|
-
if (model)
|
|
56
|
-
body.model = model;
|
|
57
|
-
const res = await fetch(`${GATEWAY_URL}/api/v1/agent`, {
|
|
58
|
-
method: "POST",
|
|
59
|
-
headers: {
|
|
60
|
-
"Content-Type": "application/json",
|
|
61
|
-
...(GATEWAY_TOKEN ? { Authorization: `Bearer ${GATEWAY_TOKEN}` } : {}),
|
|
62
|
-
},
|
|
63
|
-
body: JSON.stringify(body),
|
|
64
|
-
signal: controller.signal,
|
|
65
|
-
});
|
|
66
|
-
if (!res.ok) {
|
|
67
|
-
const text = await res.text().catch(() => "");
|
|
68
|
-
throw new Error(`OpenClaw gateway ${res.status}: ${text.slice(0, 300)}`);
|
|
69
|
-
}
|
|
70
|
-
const data = await res.json();
|
|
71
|
-
return String(data.result ?? data.message ?? data.content ?? data.text ?? JSON.stringify(data));
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
75
|
-
// External cancellation wins over "timeout" framing so the terminal
|
|
76
|
-
// event the job emits reflects the user action, not a stale timer.
|
|
77
|
-
if (external?.aborted)
|
|
78
|
-
throw err;
|
|
79
|
-
throw new Error("OpenClaw gateway timed out after 2 minutes");
|
|
80
|
-
}
|
|
81
|
-
throw err;
|
|
82
|
-
}
|
|
83
|
-
finally {
|
|
84
|
-
clearTimeout(timer);
|
|
85
|
-
external?.removeEventListener("abort", onExternalAbort);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// ─── Public API (mirrors claudeClient.js) ────────────────────────────────────
|
|
89
|
-
export async function checkResolution(issue, diffs, model, opts = {}) {
|
|
90
|
-
const text = await callGateway(buildCheckResolutionPrompt(issue, diffs), model, opts);
|
|
91
|
-
const data = extractJSON(text);
|
|
92
|
-
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
93
|
-
}
|
|
94
|
-
export async function identifyRelevantFiles(issue, fileTree, model, opts = {}) {
|
|
95
|
-
const text = await callGateway(buildIdentifyFilesPrompt(issue, fileTree), model, opts);
|
|
96
|
-
const data = extractJSON(text);
|
|
97
|
-
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
98
|
-
}
|
|
99
|
-
export async function proposeFix(issue, fileContents, options = {}, model, opts = {}) {
|
|
100
|
-
const text = await callGateway(buildProposeFixPrompt(issue, fileContents, options), model, opts);
|
|
101
|
-
const data = extractJSON(text);
|
|
102
|
-
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
103
|
-
}
|
|
104
|
-
export async function refineOrAsk(issue, fileContents, options = {}, model, _onEvent, opts = {}) {
|
|
105
|
-
// OpenClaw is a single HTTP round-trip — no streaming surface. The onEvent
|
|
106
|
-
// callback is accepted for signature parity with claudeClient and ignored.
|
|
107
|
-
const text = await callGateway(buildRefineOrAskPrompt(issue, fileContents, options), model, opts);
|
|
108
|
-
const data = extractJSON(text);
|
|
109
|
-
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=openclawClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclawClient.js","sourceRoot":"","sources":["../../../../server/forge/core/openclawClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AAsDtB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AACjD,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,iFAAiF;AAEjF,SAAS,WAAW,CAAC,IAAY;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC1D,IAAI,MAAM;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9E,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAA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AAiB,EAAE,YAA2B,EAAE,UAAyB,EAAE,EAAE,KAAyB,EAAE,QAAiD,EAAE,OAAwB,EAAE;IACtN,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAClG,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC;AACnI,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/forge/core/quotaClient.js
|
|
3
|
-
*
|
|
4
|
-
* One-off probe of the Anthropic Messages API to read the plan-level
|
|
5
|
-
* rate-limit headers. Used by the "Refresh quota" button in the UsageWidget.
|
|
6
|
-
*
|
|
7
|
-
* The rest of Forge still runs through `claude` CLI (subscription billing);
|
|
8
|
-
* this probe is the only place that spends API credits, and only when the
|
|
9
|
-
* user explicitly asks for it. Cost is negligible — one request with
|
|
10
|
-
* `max_tokens=1` against Haiku.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @param {Headers} headers
|
|
14
|
-
* @returns {null | {
|
|
15
|
-
* tokensLimit: number|null,
|
|
16
|
-
* tokensRemaining: number|null,
|
|
17
|
-
* tokensReset: string|null,
|
|
18
|
-
* requestsLimit: number|null,
|
|
19
|
-
* requestsRemaining: number|null,
|
|
20
|
-
* requestsReset: string|null,
|
|
21
|
-
* }}
|
|
22
|
-
*/
|
|
23
|
-
export declare function parseRateLimit(headers: Headers): {
|
|
24
|
-
tokensLimit: number;
|
|
25
|
-
tokensRemaining: number;
|
|
26
|
-
tokensReset: string;
|
|
27
|
-
requestsLimit: number;
|
|
28
|
-
requestsRemaining: number;
|
|
29
|
-
requestsReset: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Fires one minimal Messages API request and returns the rate-limit snapshot
|
|
33
|
-
* from the response headers.
|
|
34
|
-
*
|
|
35
|
-
* @throws if ANTHROPIC_API_KEY is not configured, or the API rejects us.
|
|
36
|
-
*/
|
|
37
|
-
export declare function probeQuota(): Promise<{
|
|
38
|
-
rateLimit: {
|
|
39
|
-
tokensLimit: number;
|
|
40
|
-
tokensRemaining: number;
|
|
41
|
-
tokensReset: string;
|
|
42
|
-
requestsLimit: number;
|
|
43
|
-
requestsRemaining: number;
|
|
44
|
-
requestsReset: string;
|
|
45
|
-
};
|
|
46
|
-
checkedAt: string;
|
|
47
|
-
}>;
|
|
48
|
-
//# sourceMappingURL=quotaClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quotaClient.d.ts","sourceRoot":"","sources":["../../../../server/forge/core/quotaClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO;;;;;;;EAiB9C;AAED;;;;;GAKG;AACH,wBAAsB,UAAU;;;;;;;;;;GA8C/B"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/forge/core/quotaClient.js
|
|
3
|
-
*
|
|
4
|
-
* One-off probe of the Anthropic Messages API to read the plan-level
|
|
5
|
-
* rate-limit headers. Used by the "Refresh quota" button in the UsageWidget.
|
|
6
|
-
*
|
|
7
|
-
* The rest of Forge still runs through `claude` CLI (subscription billing);
|
|
8
|
-
* this probe is the only place that spends API credits, and only when the
|
|
9
|
-
* user explicitly asks for it. Cost is negligible — one request with
|
|
10
|
-
* `max_tokens=1` against Haiku.
|
|
11
|
-
*/
|
|
12
|
-
const PROBE_MODEL = "claude-haiku-4-5-20251001";
|
|
13
|
-
function num(v) {
|
|
14
|
-
const n = Number(v);
|
|
15
|
-
return Number.isFinite(n) ? n : null;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @param {Headers} headers
|
|
19
|
-
* @returns {null | {
|
|
20
|
-
* tokensLimit: number|null,
|
|
21
|
-
* tokensRemaining: number|null,
|
|
22
|
-
* tokensReset: string|null,
|
|
23
|
-
* requestsLimit: number|null,
|
|
24
|
-
* requestsRemaining: number|null,
|
|
25
|
-
* requestsReset: string|null,
|
|
26
|
-
* }}
|
|
27
|
-
*/
|
|
28
|
-
export function parseRateLimit(headers) {
|
|
29
|
-
const rl = {
|
|
30
|
-
tokensLimit: num(headers.get("anthropic-ratelimit-tokens-limit")),
|
|
31
|
-
tokensRemaining: num(headers.get("anthropic-ratelimit-tokens-remaining")),
|
|
32
|
-
tokensReset: headers.get("anthropic-ratelimit-tokens-reset") ?? null,
|
|
33
|
-
requestsLimit: num(headers.get("anthropic-ratelimit-requests-limit")),
|
|
34
|
-
requestsRemaining: num(headers.get("anthropic-ratelimit-requests-remaining")),
|
|
35
|
-
requestsReset: headers.get("anthropic-ratelimit-requests-reset") ?? null,
|
|
36
|
-
};
|
|
37
|
-
const any = rl.tokensLimit !== null ||
|
|
38
|
-
rl.tokensRemaining !== null ||
|
|
39
|
-
rl.tokensReset ||
|
|
40
|
-
rl.requestsLimit !== null ||
|
|
41
|
-
rl.requestsRemaining !== null ||
|
|
42
|
-
rl.requestsReset;
|
|
43
|
-
return any ? rl : null;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Fires one minimal Messages API request and returns the rate-limit snapshot
|
|
47
|
-
* from the response headers.
|
|
48
|
-
*
|
|
49
|
-
* @throws if ANTHROPIC_API_KEY is not configured, or the API rejects us.
|
|
50
|
-
*/
|
|
51
|
-
export async function probeQuota() {
|
|
52
|
-
if (!process.env.ANTHROPIC_API_KEY) {
|
|
53
|
-
const err = Object.assign(new Error("Quota check requires ANTHROPIC_API_KEY to be set. Add it to your .env."), { status: 400 });
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
const controller = new AbortController();
|
|
57
|
-
const timer = setTimeout(() => controller.abort(), 10_000);
|
|
58
|
-
let res;
|
|
59
|
-
try {
|
|
60
|
-
res = await fetch("https://api.anthropic.com/v1/messages", {
|
|
61
|
-
method: "POST",
|
|
62
|
-
headers: {
|
|
63
|
-
"x-api-key": process.env.ANTHROPIC_API_KEY,
|
|
64
|
-
"anthropic-version": "2023-06-01",
|
|
65
|
-
"content-type": "application/json",
|
|
66
|
-
},
|
|
67
|
-
body: JSON.stringify({
|
|
68
|
-
model: PROBE_MODEL,
|
|
69
|
-
max_tokens: 1,
|
|
70
|
-
messages: [{ role: "user", content: "." }],
|
|
71
|
-
}),
|
|
72
|
-
signal: controller.signal,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
clearTimeout(timer);
|
|
77
|
-
}
|
|
78
|
-
// Rate-limit headers are present even on 4xx/5xx responses, so grab them
|
|
79
|
-
// before deciding whether to throw.
|
|
80
|
-
const rateLimit = parseRateLimit(res.headers);
|
|
81
|
-
if (!res.ok) {
|
|
82
|
-
const text = await res.text().catch(() => "");
|
|
83
|
-
const err = Object.assign(new Error(`Anthropic API ${res.status}: ${text.slice(0, 300)}`), { status: res.status, rateLimit });
|
|
84
|
-
throw err;
|
|
85
|
-
}
|
|
86
|
-
return { rateLimit, checkedAt: new Date().toISOString() };
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=quotaClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quotaClient.js","sourceRoot":"","sources":["../../../../server/forge/core/quotaClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAEhD,SAAS,GAAG,CAAC,CAAgB;IAC5B,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC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AAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/forge/core/selfImprove.ts
|
|
3
|
-
*
|
|
4
|
-
* Self-improvement engine. Reads telemetry patterns, generates actionable
|
|
5
|
-
* issues against Forge's own repo, and optionally ships them.
|
|
6
|
-
*
|
|
7
|
-
* The engine never auto-merges — it creates issues and MRs that a human
|
|
8
|
-
* reviews. Rejected MRs feed back into telemetry as learning signals.
|
|
9
|
-
*
|
|
10
|
-
* Flow:
|
|
11
|
-
* 1. evaluate() reads failure patterns from telemetry
|
|
12
|
-
* 2. Each pattern is classified into an improvement category
|
|
13
|
-
* 3. For actionable patterns, an issue is drafted with diagnosis + evidence
|
|
14
|
-
* 4. createSelfIssue() opens the issue on the configured self-repo
|
|
15
|
-
* 5. Optionally, shipSelfIssue() runs `forge ship <iid>` against it
|
|
16
|
-
*/
|
|
17
|
-
import type { FailurePattern, TelemetrySummary } from "./telemetry.ts";
|
|
18
|
-
export type ImprovementCategory = "timeout-tuning" | "prompt-quality" | "provider-bug" | "validation-gap" | "error-handling" | "performance" | "ux-improvement";
|
|
19
|
-
export interface Diagnosis {
|
|
20
|
-
category: ImprovementCategory;
|
|
21
|
-
title: string;
|
|
22
|
-
description: string;
|
|
23
|
-
evidence: string[];
|
|
24
|
-
severity: "low" | "medium" | "high";
|
|
25
|
-
confidence: "high" | "medium" | "low";
|
|
26
|
-
pattern: FailurePattern;
|
|
27
|
-
}
|
|
28
|
-
export interface EvaluationResult {
|
|
29
|
-
summary: TelemetrySummary;
|
|
30
|
-
patterns: FailurePattern[];
|
|
31
|
-
diagnoses: Diagnosis[];
|
|
32
|
-
timestamp: string;
|
|
33
|
-
}
|
|
34
|
-
export declare function evaluate(): Promise<EvaluationResult>;
|
|
35
|
-
export declare function formatIssueBody(diagnosis: Diagnosis): string;
|
|
36
|
-
export interface AutoEvalResult {
|
|
37
|
-
skipped: boolean;
|
|
38
|
-
reason?: string;
|
|
39
|
-
diagnoses?: Diagnosis[];
|
|
40
|
-
issuesCreated?: number;
|
|
41
|
-
}
|
|
42
|
-
export declare function maybeAutoEvaluate(): Promise<AutoEvalResult>;
|
|
43
|
-
//# sourceMappingURL=selfImprove.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selfImprove.d.ts","sourceRoot":"","sources":["../../../../server/forge/core/selfImprove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAkB,MAAM,gBAAgB,CAAC;AAIvF,MAAM,MAAM,mBAAmB,GAC5B,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,gBAAgB,CAAC;AAEpB,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,OAAO,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CAClB;AA+MD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC,CA2C1D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CA6B5D;AA0CD,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAcD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC,CA0DjE"}
|