feat: manually mirror opencoze's code from bytedance

Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
fanlv
2025-07-20 17:36:12 +08:00
commit 890153324f
14811 changed files with 1923430 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type FC } from 'react';
type IProps = Record<string, unknown>;
export const BizMessageInnerAddonBottom: FC<IProps> = () => (
<div>hello world</div>
);

View File

@@ -0,0 +1,18 @@
import { type PluginRegistryEntry } from '@coze-common/chat-area';
import { type PluginBizContext } from './types/biz-context';
import { BizPlugin } from './plugin';
// eslint-disable-next-line @typescript-eslint/naming-convention -- 插件命名大写开头符合预期
export const BizPluginRegistry: PluginRegistryEntry<PluginBizContext> = {
/**
* 贯穿插件生命周期、组件的上下文
*/
createPluginBizContext() {
return {};
},
/**
* 插件本体
*/
Plugin: BizPlugin,
};

View File

@@ -0,0 +1,40 @@
import {
PluginMode,
PluginName,
WriteableChatAreaPlugin,
createCustomComponents,
createWriteableLifeCycleServices,
} from '@coze-common/chat-area';
import { type PluginBizContext } from './types/biz-context';
import { bizLifeCycleServiceGenerator } from './services/life-cycle';
import { BizMessageInnerAddonBottom } from './custom-components/message-inner-addon-bottom';
export class BizPlugin extends WriteableChatAreaPlugin<PluginBizContext> {
/**
* 插件类型
* PluginMode.Readonly = 只读模式
* PluginMode.Writeable = 可写模式
*/
public pluginMode = PluginMode.Writeable;
/**
* 插件名称
* 请点 PluginName 里面去定义
*/
public pluginName = PluginName.Demo;
/**
* 生命周期服务
*/
public lifeCycleServices = createWriteableLifeCycleServices(
this,
bizLifeCycleServiceGenerator,
);
/**
* 自定义组件
*/
public customComponents = createCustomComponents({
MessageInnerBottomSlot: BizMessageInnerAddonBottom,
});
}

View File

@@ -0,0 +1,7 @@
import { type WriteableAppLifeCycleServiceGenerator } from '@coze-common/chat-area';
import { type PluginBizContext } from '../../types/biz-context';
export const appLifeCycleServiceGenerator: WriteableAppLifeCycleServiceGenerator<
PluginBizContext
> = plugin => ({});

View File

@@ -0,0 +1,7 @@
import { type WriteableCommandLifeCycleServiceGenerator } from '@coze-common/chat-area';
import { type PluginBizContext } from '../../types/biz-context';
export const commandLifeCycleServiceGenerator: WriteableCommandLifeCycleServiceGenerator<
PluginBizContext
> = plugin => ({});

View File

@@ -0,0 +1,16 @@
import { type WriteableLifeCycleServiceGenerator } from '@coze-common/chat-area';
import { type PluginBizContext } from '../../types/biz-context';
import { renderLifeCycleServiceGenerator } from './render';
import { messageLifeCycleServiceGenerator } from './message';
import { commandLifeCycleServiceGenerator } from './command';
import { appLifeCycleServiceGenerator } from './app';
export const bizLifeCycleServiceGenerator: WriteableLifeCycleServiceGenerator<
PluginBizContext
> = plugin => ({
appLifeCycleService: appLifeCycleServiceGenerator(plugin),
messageLifeCycleService: messageLifeCycleServiceGenerator(plugin),
commandLifeCycleService: commandLifeCycleServiceGenerator(plugin),
renderLifeCycleService: renderLifeCycleServiceGenerator(plugin),
});

View File

@@ -0,0 +1,7 @@
import { type WriteableMessageLifeCycleServiceGenerator } from '@coze-common/chat-area';
import { type PluginBizContext } from '../../types/biz-context';
export const messageLifeCycleServiceGenerator: WriteableMessageLifeCycleServiceGenerator<
PluginBizContext
> = plugin => ({});

View File

@@ -0,0 +1,7 @@
import { type WriteableRenderLifeCycleServiceGenerator } from '@coze-common/chat-area';
import { type PluginBizContext } from '../../types/biz-context';
export const renderLifeCycleServiceGenerator: WriteableRenderLifeCycleServiceGenerator<
PluginBizContext
> = plugin => ({});

View File

@@ -0,0 +1 @@
export type PluginBizContext = Record<string, unknown>;

View File

@@ -0,0 +1 @@
/// <reference types='@coze-arch/bot-typings' />