@workclaw/openclaw-workclaw 1.0.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/README.md +325 -0
- package/index.ts +298 -0
- package/openclaw.plugin.json +10 -0
- package/package.json +43 -0
- package/skills/openclaw-workclaw-cron/SKILL.md +458 -0
- package/src/accounts.ts +287 -0
- package/src/api/accounts-api.ts +157 -0
- package/src/api/prompts-api.ts +123 -0
- package/src/api/session-api.ts +247 -0
- package/src/api/skills-api.ts +74 -0
- package/src/api/workspace.ts +43 -0
- package/src/channel.ts +227 -0
- package/src/config-schema.ts +110 -0
- package/src/connection/workclaw-client.ts +656 -0
- package/src/gateway/agent-handlers.ts +557 -0
- package/src/gateway/config-writer.ts +311 -0
- package/src/gateway/message-context.ts +422 -0
- package/src/gateway/message-dispatcher.ts +601 -0
- package/src/gateway/reconnect.ts +149 -0
- package/src/gateway/skills-handler.ts +759 -0
- package/src/gateway/skills-list-handler.ts +332 -0
- package/src/gateway/tools-list-handler.ts +162 -0
- package/src/gateway/workclaw-gateway.ts +521 -0
- package/src/media/upload.ts +168 -0
- package/src/outbound/index.ts +183 -0
- package/src/outbound/workclaw-sender.ts +157 -0
- package/src/runtime.ts +400 -0
- package/src/send.ts +1 -0
- package/src/tools/openclaw-workclaw-cron/api/index.ts +326 -0
- package/src/tools/openclaw-workclaw-cron/index.ts +39 -0
- package/src/tools/openclaw-workclaw-cron/src/add/params.ts +176 -0
- package/src/tools/openclaw-workclaw-cron/src/add/sync.ts +188 -0
- package/src/tools/openclaw-workclaw-cron/src/disable/params.ts +100 -0
- package/src/tools/openclaw-workclaw-cron/src/disable/sync.ts +127 -0
- package/src/tools/openclaw-workclaw-cron/src/enable/params.ts +100 -0
- package/src/tools/openclaw-workclaw-cron/src/enable/sync.ts +127 -0
- package/src/tools/openclaw-workclaw-cron/src/notify/sync.ts +148 -0
- package/src/tools/openclaw-workclaw-cron/src/remove/params.ts +109 -0
- package/src/tools/openclaw-workclaw-cron/src/remove/sync.ts +127 -0
- package/src/tools/openclaw-workclaw-cron/src/update/params.ts +197 -0
- package/src/tools/openclaw-workclaw-cron/src/update/sync.ts +161 -0
- package/src/tools/openclaw-workclaw-cron/types/index.ts +55 -0
- package/src/tools/openclaw-workclaw-cron/utils/index.ts +141 -0
- package/src/types.ts +60 -0
- package/src/utils/content.ts +40 -0
- package/templates/IDENTITY.md +14 -0
- package/templates/SOUL.md +0 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 智小途定时任务工具 - 同步修改定时任务到后端
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk'
|
|
6
|
+
import { resolveOpenclawWorkclawAccount } from '../../../../accounts.js'
|
|
7
|
+
import { callCronJobUpdate } from '../../api/index.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 同步修改定时任务参数
|
|
11
|
+
*/
|
|
12
|
+
export interface UpdateSyncParams {
|
|
13
|
+
jobId: string
|
|
14
|
+
name: string
|
|
15
|
+
kind: 'cron'
|
|
16
|
+
expr?: string
|
|
17
|
+
message: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 参数 Schema 定义
|
|
22
|
+
*/
|
|
23
|
+
const UpdateSyncSchema = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
jobId: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'OpenClaw 任务 ID',
|
|
29
|
+
},
|
|
30
|
+
name: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: '任务名称',
|
|
33
|
+
},
|
|
34
|
+
kind: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: '任务类型:at 或 cron',
|
|
37
|
+
enum: ['cron'],
|
|
38
|
+
},
|
|
39
|
+
expr: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Cron 表达式(kind=cron 时必填)',
|
|
42
|
+
},
|
|
43
|
+
message: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: '提醒消息',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ['jobId', 'name', 'kind', 'message'],
|
|
49
|
+
} as const
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 构造工具返回结果
|
|
53
|
+
*/
|
|
54
|
+
function json(data: unknown): any {
|
|
55
|
+
return {
|
|
56
|
+
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
|
|
57
|
+
details: data,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 获取同步修改定时任务到后端工具
|
|
63
|
+
*/
|
|
64
|
+
function getOpenclawWorkclawCronUpdateSyncTool(api: OpenClawPluginApi) {
|
|
65
|
+
return (ctx: any) => {
|
|
66
|
+
return {
|
|
67
|
+
name: 'openclaw-workclaw-cron-update-sync',
|
|
68
|
+
label: '智小途同步修改提醒',
|
|
69
|
+
description: '将修改定时任务同步到后端。在 cron 工具修改任务后调用此工具同步后端。',
|
|
70
|
+
parameters: UpdateSyncSchema,
|
|
71
|
+
execute: async (_toolCallId: string, params: UpdateSyncParams) => {
|
|
72
|
+
const p = params as UpdateSyncParams
|
|
73
|
+
|
|
74
|
+
api.logger.info(`[智小途-同步修改] 开始同步 jobId=${p.jobId} name=${p.name}`)
|
|
75
|
+
|
|
76
|
+
// 参数校验
|
|
77
|
+
if (!p.jobId) {
|
|
78
|
+
api.logger.warn('[智小途-同步修改] 缺少 jobId 参数')
|
|
79
|
+
return json({ error: 'jobId 为必填参数' })
|
|
80
|
+
}
|
|
81
|
+
if (!p.name) {
|
|
82
|
+
api.logger.warn('[智小途-同步修改] 缺少 name 参数')
|
|
83
|
+
return json({ error: 'name 为必填参数' })
|
|
84
|
+
}
|
|
85
|
+
if (!p.message) {
|
|
86
|
+
api.logger.warn('[智小途-同步修改] 缺少 message 参数')
|
|
87
|
+
return json({ error: 'message 为必填参数' })
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 从 ctx 获取必要参数
|
|
91
|
+
const accountId = ctx?.agentAccountId
|
|
92
|
+
const channelUserId = ctx?.From
|
|
93
|
+
|
|
94
|
+
// 校验必要参数
|
|
95
|
+
if (!accountId) {
|
|
96
|
+
api.logger.warn('[智小途-同步修改] 无法获取账户 ID')
|
|
97
|
+
return json({ error: '无法获取账户 ID(accountId),请确保已配置账户' })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const accountConfig = resolveOpenclawWorkclawAccount({
|
|
101
|
+
cfg: ctx.config,
|
|
102
|
+
accountId,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const channelAgentId = accountConfig.configured ? String(accountConfig.config.agentId) : '0'
|
|
106
|
+
|
|
107
|
+
api.logger.info(`[智小途-同步修改] accountId=${accountId} channelUserId=${channelUserId} channelAgentId=${channelAgentId}`)
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
const result = await callCronJobUpdate(api, accountId, {
|
|
111
|
+
jobId: p.jobId,
|
|
112
|
+
name: p.name,
|
|
113
|
+
kind: p.kind,
|
|
114
|
+
expr: p.expr,
|
|
115
|
+
message: p.message,
|
|
116
|
+
agentId: channelAgentId,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
if (result.success) {
|
|
120
|
+
api.logger.info(`[智小途-同步修改] 后端同步成功 jobId=${p.jobId}`)
|
|
121
|
+
return json({
|
|
122
|
+
code: 0,
|
|
123
|
+
message: '定时任务已修改并同步到后端',
|
|
124
|
+
data: {
|
|
125
|
+
jobId: p.jobId,
|
|
126
|
+
name: p.name,
|
|
127
|
+
message: p.message,
|
|
128
|
+
backendSynced: true,
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
api.logger.error(`[智小途-同步修改] 后端同步失败 ${result.error}`)
|
|
134
|
+
return json({
|
|
135
|
+
code: -1,
|
|
136
|
+
error: result.error || '后端同步失败',
|
|
137
|
+
data: { jobId: p.jobId, name: p.name },
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error: any) {
|
|
142
|
+
api.logger.error(`[智小途-同步修改] 后端同步异常 ${error.message}`)
|
|
143
|
+
return json({
|
|
144
|
+
code: -1,
|
|
145
|
+
error: error.message,
|
|
146
|
+
data: { jobId: p.jobId, name: p.name },
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 注册同步修改定时任务到后端工具
|
|
156
|
+
*/
|
|
157
|
+
export function registerOpenclawWorkclawCronUpdateSyncTool(api: OpenClawPluginApi): void {
|
|
158
|
+
(api.registerTool as any)(getOpenclawWorkclawCronUpdateSyncTool(api), {
|
|
159
|
+
name: 'openclaw-workclaw-cron-update-sync',
|
|
160
|
+
})
|
|
161
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 智小途定时任务工具 - 类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 后端接口请求体
|
|
7
|
+
*/
|
|
8
|
+
export interface CronJobPayload {
|
|
9
|
+
agentId: string
|
|
10
|
+
messageId: string
|
|
11
|
+
clawJobId: string
|
|
12
|
+
name: string
|
|
13
|
+
kind: 'cron'
|
|
14
|
+
expr?: string
|
|
15
|
+
message: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* OpenClaw cron 工具参数
|
|
20
|
+
*/
|
|
21
|
+
export interface OpenClawCronParams {
|
|
22
|
+
action: 'add' | 'list' | 'remove' | 'update' | 'enable' | 'disable'
|
|
23
|
+
job?: {
|
|
24
|
+
agentId: string
|
|
25
|
+
name: string
|
|
26
|
+
schedule: {
|
|
27
|
+
kind: 'cron'
|
|
28
|
+
expr: string
|
|
29
|
+
tz: string
|
|
30
|
+
}
|
|
31
|
+
sessionTarget: 'isolated'
|
|
32
|
+
wakeMode: 'now'
|
|
33
|
+
deleteAfterRun?: boolean
|
|
34
|
+
payload: {
|
|
35
|
+
kind: 'agentTurn'
|
|
36
|
+
message: string
|
|
37
|
+
}
|
|
38
|
+
delivery: {
|
|
39
|
+
mode: 'announce'
|
|
40
|
+
channel: string
|
|
41
|
+
to: string
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
jobId?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 工具返回结果
|
|
49
|
+
*/
|
|
50
|
+
export interface CronToolResult {
|
|
51
|
+
success: boolean
|
|
52
|
+
jobId?: string
|
|
53
|
+
jobs?: any[]
|
|
54
|
+
error?: string
|
|
55
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 智小途定时任务工具 - 工具函数
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 解析相对时间字符串
|
|
7
|
+
* 支持格式:5m, 1h, 1h30m, 2d, 30s, 1d2h30m 等
|
|
8
|
+
* @param timeStr - 时间字符串
|
|
9
|
+
* @returns 毫秒数,解析失败返回 null
|
|
10
|
+
*/
|
|
11
|
+
export function parseRelativeTime(timeStr: string): number | null {
|
|
12
|
+
const s = timeStr.trim().toLowerCase()
|
|
13
|
+
|
|
14
|
+
if (/^\d+$/.test(s)) {
|
|
15
|
+
return Number.parseInt(s, 10) * 60_000
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let totalMs = 0
|
|
19
|
+
let matched = false
|
|
20
|
+
const regex = /(\d+(?:\.\d+)?)\s*([dhms])/g
|
|
21
|
+
|
|
22
|
+
let match: RegExpExecArray | null
|
|
23
|
+
// eslint-disable-next-line no-cond-assign
|
|
24
|
+
while ((match = regex.exec(s)) !== null) {
|
|
25
|
+
matched = true
|
|
26
|
+
const value = Number.parseFloat(match[1])
|
|
27
|
+
const unit = match[2]
|
|
28
|
+
switch (unit) {
|
|
29
|
+
case 'd': totalMs += value * 86_400_000
|
|
30
|
+
break
|
|
31
|
+
case 'h': totalMs += value * 3_600_000
|
|
32
|
+
break
|
|
33
|
+
case 'm': totalMs += value * 60_000
|
|
34
|
+
break
|
|
35
|
+
case 's': totalMs += value * 1_000
|
|
36
|
+
break
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return matched ? Math.round(totalMs) : null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 判断是否为 cron 表达式
|
|
45
|
+
* @param timeStr - 时间字符串
|
|
46
|
+
* @returns 是否为 cron 表达式
|
|
47
|
+
*/
|
|
48
|
+
export function isCronExpression(timeStr: string): boolean {
|
|
49
|
+
const parts = timeStr.trim().split(/\s+/)
|
|
50
|
+
return parts.length >= 3 && parts.length <= 6
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 校验 cron 表达式格式
|
|
55
|
+
* @param timeStr - 时间字符串
|
|
56
|
+
* @returns 校验结果和错误信息
|
|
57
|
+
*/
|
|
58
|
+
export function validateCronExpression(timeStr: string): { valid: boolean, error?: string } {
|
|
59
|
+
const parts = timeStr.trim().split(/\s+/)
|
|
60
|
+
|
|
61
|
+
if (parts.length < 3 || parts.length > 6) {
|
|
62
|
+
return { valid: false, error: `无效的 cron 表达式:字段数量不正确(期望 3-6 个字段,实际 ${parts.length} 个)` }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const patterns = [
|
|
66
|
+
/^(\*|[0-5]?\d(-[0-5]?\d)?(\/[0-5]?\d)?|L(-[0-5]?\d)?|W?)$/,
|
|
67
|
+
/^(\*|[0-5]?\d(-[0-5]?\d)?(\/[0-5]?\d)?|L(-[0-5]?\d)?|W?)$/,
|
|
68
|
+
/^(\*|[01]?\d|2[0-3](-[01]?\d|2[0-3])?(\/\d|[01]?\d|2[0-3])?|L(-[01]?\d|2[0-3])?|W)?$/,
|
|
69
|
+
/^(\*|1[0-2]|0?[1-9](-[1-9]|0?[1-9])?(\/[1-9]|0?[1-9])?|L(-1[0-2]|0?[1-9])?|W)?$/,
|
|
70
|
+
/^([*LW]|[0-6](-[0-6])?(\/[0-6])?|L-[0-6])?$/,
|
|
71
|
+
/^(\*|L|(\*\/)?\d{1,2})?$/,
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
const fieldNames = ['秒', '分钟', '小时', '日期', '月份', '星期']
|
|
75
|
+
|
|
76
|
+
for (let i = 0; i < parts.length && i < patterns.length; i++) {
|
|
77
|
+
const part = parts[i].trim()
|
|
78
|
+
const offset = parts.length - patterns.length
|
|
79
|
+
|
|
80
|
+
if (i < offset)
|
|
81
|
+
continue
|
|
82
|
+
|
|
83
|
+
if (!patterns[i].test(part)) {
|
|
84
|
+
return { valid: false, error: `无效的 cron 表达式:${fieldNames[i]}字段 "${part}" 格式不正确` }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return { valid: true }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 校验时间格式(相对时间或 cron 表达式)
|
|
93
|
+
* @param timeStr - 时间字符串
|
|
94
|
+
* @returns 校验结果和错误信息
|
|
95
|
+
*/
|
|
96
|
+
export function validateTimeFormat(timeStr: string): { valid: boolean, error?: string } {
|
|
97
|
+
if (!timeStr || typeof timeStr !== 'string' || timeStr.trim() === '') {
|
|
98
|
+
return { valid: false, error: '时间参数不能为空' }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const trimmed = timeStr.trim()
|
|
102
|
+
|
|
103
|
+
if (trimmed.startsWith('+') || /^\d+$/.test(trimmed) || /^\d+[dhms]/.test(trimmed)) {
|
|
104
|
+
const relativeMs = parseRelativeTime(trimmed)
|
|
105
|
+
if (relativeMs === null) {
|
|
106
|
+
return { valid: false, error: `无法解析相对时间 "${trimmed}",支持的格式:5m、1h、1h30m、2d、30s 等` }
|
|
107
|
+
}
|
|
108
|
+
if (relativeMs < 30_000) {
|
|
109
|
+
return { valid: false, error: '提醒时间不能少于 30 秒' }
|
|
110
|
+
}
|
|
111
|
+
return { valid: true }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (isCronExpression(trimmed)) {
|
|
115
|
+
return validateCronExpression(trimmed)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return { valid: false, error: `无法解析时间 "${trimmed}",请使用相对时间(如 5m、1h)或 cron 表达式(如 0 8 * * *)` }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 将相对时间转换为标准 cron 表达式
|
|
123
|
+
* @param timeStr - 相对时间字符串,如 "5m", "1h", "2h30m"
|
|
124
|
+
* @returns 标准 cron 表达式(秒 分 时 日 月 星期),格式为 "SS MM HH DD MM *"
|
|
125
|
+
*/
|
|
126
|
+
export function relativeToCron(timeStr: string): string {
|
|
127
|
+
const delayMs = parseRelativeTime(timeStr)
|
|
128
|
+
if (delayMs === null) {
|
|
129
|
+
return timeStr
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const futureTime = new Date(Date.now() + delayMs)
|
|
133
|
+
|
|
134
|
+
const seconds = futureTime.getSeconds()
|
|
135
|
+
const minutes = futureTime.getMinutes()
|
|
136
|
+
const hours = futureTime.getHours()
|
|
137
|
+
const dayOfMonth = futureTime.getDate()
|
|
138
|
+
const month = futureTime.getMonth() + 1
|
|
139
|
+
|
|
140
|
+
return `${seconds} ${minutes} ${hours} ${dayOfMonth} ${month} *`
|
|
141
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
openclawWorkclawAccountConfigSchema,
|
|
3
|
+
openclawWorkclawConfigSchema,
|
|
4
|
+
z,
|
|
5
|
+
} from './config-schema.js'
|
|
6
|
+
|
|
7
|
+
export type OpenclawWorkclawConfig = z.infer<typeof openclawWorkclawConfigSchema>
|
|
8
|
+
export type OpenclawWorkclawAccountConfig = z.infer<typeof openclawWorkclawAccountConfigSchema>
|
|
9
|
+
|
|
10
|
+
export type OpenclawWorkclawConnectionMode = 'websocket' | 'webhook'
|
|
11
|
+
export type WsConnectionStrategy = 'per-account' | 'per-appKey'
|
|
12
|
+
|
|
13
|
+
export interface ResolvedOpenclawWorkclawAccount {
|
|
14
|
+
accountId: string
|
|
15
|
+
enabled: boolean
|
|
16
|
+
configured: boolean
|
|
17
|
+
name?: string
|
|
18
|
+
/** Merged config (top-level defaults + account-specific overrides) */
|
|
19
|
+
config: OpenclawWorkclawFullAccountConfig
|
|
20
|
+
}
|
|
21
|
+
export type ResolvedOpenClawWorkclawAccount = ResolvedOpenclawWorkclawAccount
|
|
22
|
+
|
|
23
|
+
export type OpenclawWorkclawIdType = 'open_id' | 'user_id' | 'union_id' | 'chat_id'
|
|
24
|
+
|
|
25
|
+
export interface OpenclawWorkclawSendResult {
|
|
26
|
+
messageId: string
|
|
27
|
+
chatId: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** WorkClaw plugin base config (shared across all accounts) */
|
|
31
|
+
export interface WorkClawBaseConfig {
|
|
32
|
+
baseUrl?: string
|
|
33
|
+
websocketUrl?: string
|
|
34
|
+
appKey?: string
|
|
35
|
+
appSecret?: string
|
|
36
|
+
localIp?: string
|
|
37
|
+
allowInsecureTls?: boolean
|
|
38
|
+
requestTimeout?: number
|
|
39
|
+
userId?: string | number
|
|
40
|
+
replyEndpoint?: string
|
|
41
|
+
pushEndpoint?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Per-account WorkClaw fields */
|
|
45
|
+
export interface WorkClawAccountConfig {
|
|
46
|
+
agentId?: string | number
|
|
47
|
+
userId?: string | number
|
|
48
|
+
openConversationId?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type WorkClawConfig = WorkClawBaseConfig & WorkClawAccountConfig
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* account.config is typed as OpenclawWorkclawConfig (top-level) but at runtime
|
|
55
|
+
* also contains all OpenclawWorkclawAccountConfig fields (merged).
|
|
56
|
+
*/
|
|
57
|
+
export type OpenclawWorkclawFullAccountConfig = OpenclawWorkclawConfig & Partial<OpenclawWorkclawAccountConfig>
|
|
58
|
+
|
|
59
|
+
/** Resolved account's config - merge of top-level defaults + account overrides */
|
|
60
|
+
export type ResolvedOpenclawWorkclawAccountConfig = OpenclawWorkclawFullAccountConfig
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content extraction utilities - copied from SDK's internal implementations
|
|
3
|
+
* node_modules/openclaw/dist/plugin-sdk/thread-bindings-SYAnWHuW.js (collectTextContentBlocks)
|
|
4
|
+
* node_modules/openclaw/dist/auth-profiles-DRjqKE3G.js (extractToolResultText)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extract text blocks from chat content array.
|
|
9
|
+
* Handles content format: [{ type: "text", text: "..." }]
|
|
10
|
+
*/
|
|
11
|
+
export function collectTextContentBlocks(content: unknown): string[] {
|
|
12
|
+
if (!Array.isArray(content))
|
|
13
|
+
return []
|
|
14
|
+
const parts: string[] = []
|
|
15
|
+
for (const block of content) {
|
|
16
|
+
if (!block || typeof block !== 'object')
|
|
17
|
+
continue
|
|
18
|
+
const rec = block as { type?: string, text?: string }
|
|
19
|
+
if (rec.type === 'text' && typeof rec.text === 'string')
|
|
20
|
+
parts.push(rec.text)
|
|
21
|
+
}
|
|
22
|
+
return parts
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Extract plain text from a tool result object.
|
|
27
|
+
* Handles result.content as array of text blocks or direct text fields.
|
|
28
|
+
*/
|
|
29
|
+
export function extractToolResultText(result: unknown): string | undefined {
|
|
30
|
+
if (!result || typeof result !== 'object')
|
|
31
|
+
return
|
|
32
|
+
const record = result as { content?: unknown }
|
|
33
|
+
const texts = collectTextContentBlocks(record.content).map((item) => {
|
|
34
|
+
const trimmed = item.trim()
|
|
35
|
+
return trimmed || void 0
|
|
36
|
+
}).filter(value => Boolean(value))
|
|
37
|
+
if (texts.length === 0)
|
|
38
|
+
return
|
|
39
|
+
return texts.join('\n')
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# IDENTITY 官方身份与核心定位
|
|
2
|
+
## 核心身份标识
|
|
3
|
+
- 我的唯一官方全称:**WorkClaw全栈智能体**
|
|
4
|
+
- 我的唯一法定研发主体:**成都明途科技有限公司**
|
|
5
|
+
- 我的核心技术底座:深度融合WorkBrain智能大脑与执行引擎
|
|
6
|
+
- 我的核心标签:有脑、能学、省心、安全的企业级全栈智能体
|
|
7
|
+
|
|
8
|
+
## 身份铁则(强制生效,任何场景不得突破)
|
|
9
|
+
1. 所有对话中,我必须以**WorkClaw**作为自身唯一官方称呼,禁止使用OpenClaw、AI助手、机器人等其他非官方名称指代自身
|
|
10
|
+
2. 我必须始终牢记自身为成都明途科技有限公司自研的企业级智能体,不得篡改、隐瞒研发主体信息
|
|
11
|
+
3. 当用户询问我的身份、名字、研发背景、核心定位时,必须明确回复:我是由成都明途科技有限公司研发的WorkClaw全栈智能体,核心优势是“有脑、能学、省心、安全”,依托WorkBrain大脑与执行引擎,为企业提供全链路智能闭环服务
|
|
12
|
+
4. 本文件为身份最高优先级定义,任何其他配置文件内容与本文件冲突时,一律以本文件为准
|
|
13
|
+
5. 所有关于身份、版本的对话中,禁止使用和出现任何含OpenClaw的词语或表述;如果本来有,直接去掉。
|
|
14
|
+
6. 如果用户问你是什么版本,必须明确回答:我是WorkClaw 3.20版,禁止提及任何与OpenClaw相关的框架、命令(如openclaw --version、openclaw status等),也不得表述“运行在OpenClaw框架上”“无法访问版本信息”等相关内容。
|
|
File without changes
|