diff --git a/.github/ubiquibot-config.yml b/.github/ubiquibot-config.yml index 336f1f1a4..3f02c40eb 100644 --- a/.github/ubiquibot-config.yml +++ b/.github/ubiquibot-config.yml @@ -1 +1 @@ -price-multiplier: 1.5 \ No newline at end of file +priceMultiplier: 1.5 \ No newline at end of file diff --git a/src/bindings/config.ts b/src/bindings/config.ts index 413e3faef..38e72260d 100644 --- a/src/bindings/config.ts +++ b/src/bindings/config.ts @@ -103,7 +103,7 @@ export const loadConfig = async (context: Context): Promise => { }, ask: { apiKey: openAIKey, - tokenLimit: openAITokenLimit, + tokenLimit: openAITokenLimit || 0, }, accessControl: enableAccessControl, }; diff --git a/src/configs/ubiquibot-config-default.ts b/src/configs/ubiquibot-config-default.ts index a5f764862..310450835 100644 --- a/src/configs/ubiquibot-config-default.ts +++ b/src/configs/ubiquibot-config-default.ts @@ -1,22 +1,19 @@ import { MergedConfig } from "../types"; -export const DefaultConfig: MergedConfig = { - "evm-network-id": 100, - "price-multiplier": 1, - "issue-creator-multiplier": 2, - "payment-permit-max-price": 9007199254740991, - "max-concurrent-assigns": 9007199254740991, - "assistive-pricing": false, - "disable-analytics": false, - "comment-incentives": false, - "register-wallet-with-verification": false, - "openai-api-key": null, - "openai-token-limit": 8000, - "stale-bounty-time": "0d", - "promotion-comment": - "\n
If you enjoy the DevPool experience, please follow Ubiquity on GitHub and star this repo to show your support. It helps a lot!
", - "default-labels": [], - "time-labels": [ +export const DefaultConfig : MergedConfig = { + evmNetworkId: 100, + priceMultiplier: 1, + issueCreatorMultiplier: 2, + paymentPermitMaxPrice: 9007199254740991, + maxConcurrentAssigns: 9007199254740991, + assistivePricing: false, + disableAnalytics: false, + commentIncentives: false, + registerWalletWithVerification: false, + promotionComment: "\n
If you enjoy the DevPool experience, please follow Ubiquity on GitHub and star this repo to show your support. It helps a lot!
", + defaultLabels: [], + timeLabels: [ + { name: "Time: <1 Hour", }, @@ -33,7 +30,7 @@ export const DefaultConfig: MergedConfig = { name: "Time: <1 Month", }, ], - "priority-labels": [ + priorityLabels: [ { name: "Priority: 1 (Normal)", }, @@ -50,7 +47,7 @@ export const DefaultConfig: MergedConfig = { name: "Priority: 5 (Emergency)", }, ], - "command-settings": [ + commandSettings: [ { name: "start", enabled: false, @@ -89,15 +86,17 @@ export const DefaultConfig: MergedConfig = { }, ], incentives: { - comment: { - elements: {}, - totals: { - word: 0, - }, - }, + + "comment": { + "elements": {}, + "totals": { + "word": 0 + } + } }, - "enable-access-control": { - label: false, - organization: true, + enableAccessControl: { + "label": false, + "organization": true }, -}; + staleBountyTime:"0d" +} diff --git a/src/handlers/push/update-base.ts b/src/handlers/push/update-base.ts index 4141d811f..da67c8e6c 100644 --- a/src/handlers/push/update-base.ts +++ b/src/handlers/push/update-base.ts @@ -21,12 +21,12 @@ export const updateBaseRate = async (context: Context, payload: PushPayload, fil const previousContent = Buffer.from(preFileContent, "base64").toString(); const previousConfig = await parseYAML(previousContent); - if (!previousConfig || !previousConfig["price-multiplier"]) { + if (!previousConfig || !previousConfig["priceMultiplier"]) { logger.debug("No multiplier found in file object"); return; } - const previousBaseRate = previousConfig["price-multiplier"]; + const previousBaseRate = previousConfig["priceMultiplier"]; // fetch all labels const repoLabels = await listLabelsForRepo(); diff --git a/src/types/config.ts b/src/types/config.ts index 4f5dde5ce..d2ea2fb75 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -106,7 +106,7 @@ export const CommentsSchema = Type.Object({ }); export const AskSchema = Type.Object({ - apiKey: Type.Union([Type.String(), Type.Null()]), + apiKey: Type.Optional(Type.String()), tokenLimit: Type.Number(), }); @@ -163,26 +163,26 @@ export type GPTResponse = Static; export const WideConfigSchema = Type.Object( { - "evm-network-id": Type.Optional(Type.Number()), - "price-multiplier": Type.Optional(Type.Number()), - "issue-creator-multiplier": Type.Optional(Type.Number()), - "time-labels": Type.Optional(Type.Array(LabelItemSchema)), - "priority-labels": Type.Optional(Type.Array(LabelItemSchema)), - "payment-permit-max-price": Type.Optional(Type.Number()), - "command-settings": Type.Optional(Type.Array(CommandItemSchema)), - "promotion-comment": Type.Optional(Type.String()), - "disable-analytics": Type.Optional(Type.Boolean()), - "comment-incentives": Type.Optional(Type.Boolean()), - "assistive-pricing": Type.Optional(Type.Boolean()), - "max-concurrent-assigns": Type.Optional(Type.Number()), + evmNetworkId: Type.Optional(Type.Number()), + priceMultiplier: Type.Optional(Type.Number()), + issueCreatorMultiplier: Type.Optional(Type.Number()), + timeLabels: Type.Optional(Type.Array(LabelItemSchema)), + priorityLabels: Type.Optional(Type.Array(LabelItemSchema)), + paymentPermitMaxPrice: Type.Optional(Type.Number()), + commandSettings: Type.Optional(Type.Array(CommandItemSchema)), + promotionComment: Type.Optional(Type.String()), + disableAnalytics: Type.Optional(Type.Boolean()), + commentIncentives: Type.Optional(Type.Boolean()), + assistivePricing: Type.Optional(Type.Boolean()), + maxConcurrentAssigns: Type.Optional(Type.Number()), incentives: Type.Optional(IncentivesSchema), - "default-labels": Type.Optional(Type.Array(Type.String())), - "register-wallet-with-verification": Type.Optional(Type.Boolean()), - "enable-access-control": Type.Optional(AccessControlSchema), - "stale-bounty-time": Type.Optional(Type.String()), - "openai-api-key": AskSchema.apiKey, - "openai-token-limit": Type.Optional(Type.Number()), - "private-key-encrypted": Type.Optional(Type.String()), + defaultLabels: Type.Optional(Type.Array(Type.String())), + registerWalletWithVerification: Type.Optional(Type.Boolean()), + enableAccessControl: Type.Optional(AccessControlSchema), + openAIKey: Type.Optional(Type.String()), + openAITokenLimit: Type.Optional(Type.Number()), + staleBountyTime: Type.Optional(Type.String()), + privateKeyEncrypted: Type.Optional(Type.String()), }, { additionalProperties: false, @@ -194,26 +194,26 @@ export type WideConfig = Static; export type WideRepoConfig = WideConfig; export const MergedConfigSchema = Type.Object({ - "evm-network-id": Type.Number(), - "price-multiplier": Type.Number(), - "private-key-encrypted": Type.Optional(Type.String()), - "issue-creator-multiplier": Type.Number(), - "time-labels": Type.Array(LabelItemSchema), - "priority-labels": Type.Array(LabelItemSchema), - "payment-permit-max-price": Type.Number(), - "command-settings": Type.Array(CommandItemSchema), - "promotion-comment": Type.String(), - "disable-analytics": Type.Boolean(), - "comment-incentives": Type.Boolean(), - "assistive-pricing": Type.Boolean(), - "max-concurrent-assigns": Type.Number(), + evmNetworkId: Type.Number(), + priceMultiplier: Type.Number(), + privateKeyEncrypted: Type.Optional(Type.String()), + issueCreatorMultiplier: Type.Number(), + timeLabels: Type.Array(LabelItemSchema), + priorityLabels: Type.Array(LabelItemSchema), + paymentPermitMaxPrice: Type.Number(), + commandSettings: Type.Array(CommandItemSchema), + promotionComment: Type.String(), + disableAnalytics: Type.Boolean(), + commentIncentives: Type.Boolean(), + assistivePricing: Type.Boolean(), + maxConcurrentAssigns: Type.Number(), incentives: IncentivesSchema, - "default-labels": Type.Array(Type.String()), - "register-wallet-with-verification": Type.Boolean(), - "enable-access-control": AccessControlSchema, - "openai-api-key": AskSchema.apiKey, - "openai-token-limit": Type.Number(), - "stale-bounty-time": Type.String(), + defaultLabels: Type.Array(Type.String()), + registerWalletWithVerification: Type.Boolean(), + enableAccessControl: AccessControlSchema, + openAIKey: Type.Optional(Type.String()), + openAITokenLimit: Type.Optional(Type.Number()), + staleBountyTime: Type.String(), }); export type MergedConfig = Static; diff --git a/src/utils/private.ts b/src/utils/private.ts index 87a4ddf63..2e2a730e6 100644 --- a/src/utils/private.ts +++ b/src/utils/private.ts @@ -10,7 +10,7 @@ import { WideConfig, WideRepoConfig, WideConfigSchema } from "../types"; const CONFIG_REPO = "ubiquibot-config"; const CONFIG_PATH = ".github/ubiquibot-config.yml"; -const KEY_NAME = "private-key-encrypted"; +const KEY_NAME = "privateKeyEncrypted"; const KEY_PREFIX = "HSK_"; export const getConfigSuperset = async (context: Context, type: "org" | "repo", filePath: string): Promise => { @@ -141,26 +141,27 @@ export const getWideConfig = async (context: Context) => { const mergedConfigData: MergedConfig = mergeConfigs(configs); const configData = { - networkId: mergedConfigData["evm-network-id"], + networkId: mergedConfigData.evmNetworkId, privateKey: privateKeyDecrypted ?? "", - assistivePricing: mergedConfigData["assistive-pricing"], - commandSettings: mergedConfigData["command-settings"], - baseMultiplier: mergedConfigData["price-multiplier"], - issueCreatorMultiplier: mergedConfigData["issue-creator-multiplier"], - timeLabels: mergedConfigData["time-labels"], - priorityLabels: mergedConfigData["priority-labels"], - paymentPermitMaxPrice: mergedConfigData["payment-permit-max-price"], - disableAnalytics: mergedConfigData["disable-analytics"], - bountyHunterMax: mergedConfigData["max-concurrent-assigns"], - incentiveMode: mergedConfigData["comment-incentives"], - incentives: mergedConfigData["incentives"], - defaultLabels: mergedConfigData["default-labels"], - promotionComment: mergedConfigData["promotion-comment"], - registerWalletWithVerification: mergedConfigData["register-wallet-with-verification"], - enableAccessControl: mergedConfigData["enable-access-control"], - openAIKey: mergedConfigData["openai-api-key"], - openAITokenLimit: mergedConfigData["openai-token-limit"], - staleBountyTime: mergedConfigData["stale-bounty-time"], + assistivePricing: mergedConfigData.assistivePricing, + commandSettings: mergedConfigData.commandSettings, + baseMultiplier: mergedConfigData.priceMultiplier, + issueCreatorMultiplier: mergedConfigData.issueCreatorMultiplier, + timeLabels: mergedConfigData.timeLabels, + priorityLabels: mergedConfigData.priorityLabels, + paymentPermitMaxPrice: mergedConfigData.paymentPermitMaxPrice, + disableAnalytics: mergedConfigData.disableAnalytics, + bountyHunterMax: mergedConfigData.maxConcurrentAssigns, + incentiveMode: mergedConfigData.commentIncentives, + incentives: mergedConfigData.incentives, + defaultLabels: mergedConfigData.defaultLabels, + promotionComment: mergedConfigData.promotionComment, + registerWalletWithVerification: mergedConfigData.registerWalletWithVerification, + enableAccessControl: mergedConfigData.enableAccessControl, + openAIKey: mergedConfigData.openAIKey, + openAITokenLimit: mergedConfigData.openAITokenLimit, + staleBountyTime: mergedConfigData.staleBountyTime, + }; return configData;