nolo-cli 0.1.32 → 0.1.34

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 (234) hide show
  1. package/README.md +4 -10
  2. package/agent-runtime/agentRecordConfig.ts +10 -0
  3. package/agent-runtime/hostAdapter.ts +10 -1
  4. package/agent-runtime/index.ts +9 -20
  5. package/agent-runtime/localLoop.ts +49 -2
  6. package/agent-runtime/localToolPolicy.ts +76 -34
  7. package/agent-runtime/localWorkspaceTools.ts +30 -333
  8. package/agent-runtime/openAiCompatibleProvider.ts +7 -3
  9. package/agent-runtime/openAiCompatibleProviderConfig.ts +15 -26
  10. package/agent-runtime/platformChatProvider.ts +47 -73
  11. package/agent-runtime/providerResolution.ts +244 -0
  12. package/agent-runtime/runtimeToolPolicy.ts +77 -29
  13. package/agent-runtime/shellCommandPolicy.ts +120 -0
  14. package/agentAliases.ts +14 -83
  15. package/agentCommandSupport.ts +3 -6
  16. package/agentInternalCommandEntries.ts +4 -13
  17. package/agentListCommands.ts +18 -27
  18. package/agentMachineCommands.ts +40 -336
  19. package/agentPullCommand.ts +30 -55
  20. package/agentRecordCommands.ts +84 -1
  21. package/agentRecordHelpers.ts +102 -186
  22. package/agentRunCommand.ts +438 -107
  23. package/agentRuntimeLocal.ts +2 -9
  24. package/ai/agent/cliExecutor.ts +19 -323
  25. package/ai/tools/toolNameAliases.ts +70 -0
  26. package/authCommands.ts +2 -36
  27. package/cli/agentAliases.ts +14 -83
  28. package/cli/agentCommandSupport.ts +3 -6
  29. package/cli/agentInternalCommandEntries.ts +4 -13
  30. package/cli/agentListCommands.ts +18 -27
  31. package/cli/agentMachineCommands.ts +40 -336
  32. package/cli/agentPullCommand.ts +30 -55
  33. package/cli/agentRecordCommands.ts +84 -1
  34. package/cli/agentRecordHelpers.ts +102 -186
  35. package/cli/agentRunCommand.ts +438 -107
  36. package/cli/agentRuntimeLocal.ts +2 -9
  37. package/cli/authCommands.ts +2 -36
  38. package/cli/cliCommandDispatch.ts +2 -2
  39. package/cli/cliEnvHelpers.ts +34 -107
  40. package/cli/client/agentRun.ts +854 -57
  41. package/cli/client/localRuntimeAdapter.ts +59 -159
  42. package/cli/client/streamingOutput.ts +3 -1
  43. package/cli/client/taskRunPrompt.ts +24 -7
  44. package/cli/commandRegistry.ts +4 -5
  45. package/cli/connectorRunArtifact.ts +10 -34
  46. package/cli/connectorWebSocketTarget.ts +6 -10
  47. package/cli/internalCommandEntries.ts +0 -8
  48. package/cli/localRuntimeDb.ts +2 -39
  49. package/cli/machineCommands.ts +189 -190
  50. package/cli/machineDaemonCommands.ts +165 -9
  51. package/cli/machineHeartbeatCommands.ts +2 -1
  52. package/cli/machineStatusCommands.ts +13 -5
  53. package/cli/machineWatchCommands.ts +1 -1
  54. package/cli/machineWsRunDispatch.ts +30 -44
  55. package/cli/machineWsSession.ts +0 -2
  56. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  57. package/cli/runtimeDoctorCommands.ts +72 -15
  58. package/cli/scriptCommandEntries.ts +45 -5
  59. package/cli/tableCommands.ts +133 -33
  60. package/cli/taskRunCommand.ts +211 -16
  61. package/cli/tui/session.ts +372 -43
  62. package/cli/workflowInternalCommandEntries.ts +0 -20
  63. package/cliCommandDispatch.ts +2 -2
  64. package/cliEnvHelpers.ts +34 -107
  65. package/client/agentConfigResolver.test.ts +2 -0
  66. package/client/agentRun.test.ts +12 -208
  67. package/client/agentRun.ts +854 -57
  68. package/client/localProviderResolver.test.ts +26 -2
  69. package/client/localRuntimeAdapter.test.ts +296 -171
  70. package/client/localRuntimeAdapter.ts +59 -159
  71. package/client/localToolPolicy.test.ts +4 -28
  72. package/client/streamingOutput.ts +3 -1
  73. package/client/taskRunPrompt.ts +24 -7
  74. package/commandRegistry.ts +4 -5
  75. package/connectorRunArtifact.ts +10 -34
  76. package/connectorWebSocketTarget.ts +6 -10
  77. package/database/server/serverStoreFactory.ts +2 -8
  78. package/internalCommandEntries.ts +0 -8
  79. package/localRuntimeDb.ts +2 -39
  80. package/machineCommands.ts +189 -190
  81. package/machineDaemonCommands.ts +165 -9
  82. package/machineHeartbeatCommands.ts +2 -1
  83. package/machineStatusCommands.ts +13 -5
  84. package/machineWatchCommands.ts +1 -1
  85. package/machineWsRunDispatch.ts +30 -44
  86. package/machineWsSession.ts +0 -2
  87. package/offlineMarxistsAgentCommand.ts +314 -0
  88. package/package.json +52 -188
  89. package/runtimeDoctorCommands.ts +72 -15
  90. package/scriptCommandEntries.ts +45 -5
  91. package/tableCommands.ts +133 -33
  92. package/taskRunCommand.ts +211 -16
  93. package/tui/session.ts +372 -43
  94. package/workflowInternalCommandEntries.ts +0 -20
  95. package/agent-runtime/dialogStatus.ts +0 -139
  96. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  97. package/agentCreateCustomCommands.ts +0 -278
  98. package/agentDialogsCommands.ts +0 -227
  99. package/agentDoctorCommands.ts +0 -203
  100. package/agentRunLocalWorkspace.ts +0 -182
  101. package/agentRunParsing.ts +0 -298
  102. package/agentSuperviseCommands.ts +0 -8
  103. package/agentUnpublishCommands.ts +0 -113
  104. package/ai/agent/agentRunDialogLineage.ts +0 -56
  105. package/ai/policy/types.ts +0 -64
  106. package/ai/skills/skillSummaryMarker.ts +0 -26
  107. package/app/types.ts +0 -358
  108. package/build.ts +0 -16
  109. package/buildPublish.ts +0 -138
  110. package/buildPublishArtifactAssembly.ts +0 -724
  111. package/buildPublishImportAnalysis.ts +0 -242
  112. package/chat/messages/fetchMessages.ts +0 -84
  113. package/chat/messages/types.ts +0 -185
  114. package/cli/agentCreateCustomCommands.ts +0 -278
  115. package/cli/agentDialogsCommands.ts +0 -227
  116. package/cli/agentDoctorCommands.ts +0 -203
  117. package/cli/agentRunLocalWorkspace.ts +0 -182
  118. package/cli/agentRunParsing.ts +0 -298
  119. package/cli/agentSuperviseCommands.ts +0 -8
  120. package/cli/agentUnpublishCommands.ts +0 -113
  121. package/cli/buildPublish.ts +0 -138
  122. package/cli/buildPublishArtifactAssembly.ts +0 -724
  123. package/cli/buildPublishImportAnalysis.ts +0 -242
  124. package/cli/cliIoTypes.ts +0 -3
  125. package/cli/cliRuntimeDoctorReport.ts +0 -193
  126. package/cli/client/agentRunInput.ts +0 -10
  127. package/cli/client/agentRunLocalExecution.ts +0 -124
  128. package/cli/client/agentRunLocalExecutor.ts +0 -179
  129. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  130. package/cli/client/agentRunServerTransport.ts +0 -397
  131. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  132. package/cli/customCodingAgentFlow.ts +0 -208
  133. package/cli/customCodingAgentRecord.ts +0 -179
  134. package/cli/dialogDataAccess.ts +0 -186
  135. package/cli/dialogInternalCommandEntries.ts +0 -11
  136. package/cli/dialogReadCommands.ts +0 -180
  137. package/cli/dialogReadHelpers.ts +0 -226
  138. package/cli/dialogStatusCommands.ts +0 -123
  139. package/cli/docInternalCommandEntries.ts +0 -20
  140. package/cli/hybridReadHelpers.ts +0 -109
  141. package/cli/machineCommandPrompts.ts +0 -79
  142. package/cli/machineCommandResolution.ts +0 -43
  143. package/cli/noloReadBridgePrompt.ts +0 -16
  144. package/cli/pageCreateCommands.ts +0 -219
  145. package/cli/pageDeleteCommands.ts +0 -167
  146. package/cli/pageReadCommands.ts +0 -151
  147. package/cli/pageUpdateCommands.ts +0 -249
  148. package/cli/pageWriteHelpers.ts +0 -209
  149. package/cli/publishPackage.ts +0 -36
  150. package/cli/runtimeInternalCommandEntries.ts +0 -15
  151. package/cli/runtimePassthroughCommands.ts +0 -22
  152. package/cli/scriptPassthroughHelpers.ts +0 -28
  153. package/cli/secretScanHelpers.ts +0 -31
  154. package/cli/spaceAttachCommands.ts +0 -134
  155. package/cli/spaceCategoryCommands.ts +0 -263
  156. package/cli/spaceCommands.ts +0 -295
  157. package/cli/spaceDeleteCommands.ts +0 -312
  158. package/cli/spaceInternalCommandEntries.ts +0 -21
  159. package/cli/spaceMutationHelpers.ts +0 -135
  160. package/cli/spaceReadCommands.ts +0 -323
  161. package/cli/tableDataOutput.ts +0 -41
  162. package/cli/tableDataSafety.ts +0 -26
  163. package/cli/tableMetaCommands.ts +0 -307
  164. package/cli/tableMutationCommands.ts +0 -266
  165. package/cli/tableQueryParsing.ts +0 -90
  166. package/cli/tableQueryRequest.ts +0 -53
  167. package/cli/taskRunActions.ts +0 -122
  168. package/cli/taskRunParsing.ts +0 -86
  169. package/cli/taskRunPromptShared.ts +0 -55
  170. package/cli/tui/tuiCatalog.ts +0 -22
  171. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  172. package/cli/tui/tuiPresentation.ts +0 -146
  173. package/cliIoTypes.ts +0 -3
  174. package/cliRuntimeDoctorReport.ts +0 -193
  175. package/client/agentRunInput.ts +0 -10
  176. package/client/agentRunLocalExecution.test.ts +0 -123
  177. package/client/agentRunLocalExecution.ts +0 -124
  178. package/client/agentRunLocalExecutor.ts +0 -179
  179. package/client/agentRunRuntimeSelection.test.ts +0 -159
  180. package/client/agentRunRuntimeSelection.ts +0 -145
  181. package/client/agentRunServerTransport.ts +0 -397
  182. package/client/agentRunTaskRunRecorder.ts +0 -176
  183. package/connector-experimental/daemonLauncher.ts +0 -223
  184. package/create/space/spaceKeys.ts +0 -65
  185. package/create/types.ts +0 -21
  186. package/customCodingAgentFlow.ts +0 -208
  187. package/customCodingAgentRecord.ts +0 -179
  188. package/database/keys.ts +0 -765
  189. package/database/tombstones.ts +0 -52
  190. package/database/utils/ulid.ts +0 -1
  191. package/dialogDataAccess.ts +0 -186
  192. package/dialogInternalCommandEntries.ts +0 -11
  193. package/dialogReadCommands.ts +0 -180
  194. package/dialogReadHelpers.ts +0 -226
  195. package/dialogStatusCommands.ts +0 -123
  196. package/docInternalCommandEntries.ts +0 -20
  197. package/hybridReadHelpers.ts +0 -109
  198. package/machineCommandPrompts.ts +0 -79
  199. package/machineCommandResolution.ts +0 -43
  200. package/noloReadBridgePrompt.ts +0 -16
  201. package/pageCreateCommands.ts +0 -219
  202. package/pageDeleteCommands.ts +0 -167
  203. package/pageReadCommands.ts +0 -151
  204. package/pageUpdateCommands.ts +0 -249
  205. package/pageWriteHelpers.ts +0 -209
  206. package/publishPackage.ts +0 -36
  207. package/runtimeInternalCommandEntries.ts +0 -15
  208. package/runtimePassthroughCommands.ts +0 -22
  209. package/scriptPassthroughHelpers.ts +0 -28
  210. package/secretScanHelpers.ts +0 -31
  211. package/share/helpers.ts +0 -302
  212. package/share/keys.ts +0 -243
  213. package/share/types.ts +0 -100
  214. package/spaceAttachCommands.ts +0 -134
  215. package/spaceCategoryCommands.ts +0 -263
  216. package/spaceCommands.ts +0 -295
  217. package/spaceDeleteCommands.ts +0 -312
  218. package/spaceInternalCommandEntries.ts +0 -21
  219. package/spaceMutationHelpers.ts +0 -135
  220. package/spaceReadCommands.ts +0 -323
  221. package/tableDataOutput.ts +0 -41
  222. package/tableDataSafety.ts +0 -26
  223. package/tableMetaCommands.ts +0 -307
  224. package/tableMutationCommands.ts +0 -266
  225. package/tableQueryParsing.ts +0 -90
  226. package/tableQueryRequest.ts +0 -53
  227. package/taskRunActions.ts +0 -122
  228. package/taskRunParsing.ts +0 -86
  229. package/taskRunPromptShared.ts +0 -55
  230. package/tui/tuiCatalog.ts +0 -22
  231. package/tui/tuiCommandInterpreter.test.ts +0 -169
  232. package/tui/tuiCommandInterpreter.ts +0 -253
  233. package/tui/tuiPresentation.test.ts +0 -154
  234. package/tui/tuiPresentation.ts +0 -146
@@ -1,64 +0,0 @@
1
- export type TonePreset =
2
- | "default"
3
- | "professional"
4
- | "friendly"
5
- | "direct"
6
- | "pragmatic";
7
-
8
- export type ToneResolutionMode = "agent_first" | "user_first" | "blend";
9
-
10
- export type KnowledgeCaptureLevel = 1 | 2 | 3 | 4;
11
- export type SpaceContextLevel = 1 | 2 | 3 | 4;
12
-
13
- export type SelfEvolutionMode =
14
- | "none"
15
- | "knowledge_only"
16
- | "prompt_and_refs"
17
- | "full";
18
-
19
- export interface AgentBasePolicy {
20
- version: 1;
21
- tone?: {
22
- preset?: TonePreset;
23
- resolutionMode?: ToneResolutionMode;
24
- };
25
- knowledgeCaptureMaxLevel: KnowledgeCaptureLevel;
26
- spaceContextMaxLevel: SpaceContextLevel;
27
- selfEvolutionMode: SelfEvolutionMode;
28
- }
29
-
30
- export interface UserPreferenceProfile {
31
- version: 1;
32
- tone?: {
33
- preset?: TonePreset;
34
- };
35
- knowledgeCaptureLevel: KnowledgeCaptureLevel;
36
- spaceContextLevel: SpaceContextLevel;
37
- }
38
-
39
- export interface DialogPolicyState {
40
- autoKnowledgeCaptureCount?: number;
41
- autoSpaceReadCount?: number;
42
- updatedAt?: number;
43
- }
44
-
45
- export const DEFAULT_AGENT_BASE_POLICY: AgentBasePolicy = {
46
- version: 1,
47
- tone: {
48
- preset: "default",
49
- resolutionMode: "blend",
50
- },
51
- knowledgeCaptureMaxLevel: 4,
52
- spaceContextMaxLevel: 4,
53
- selfEvolutionMode: "knowledge_only",
54
- };
55
-
56
- export const DEFAULT_USER_PREFERENCE_PROFILE: UserPreferenceProfile = {
57
- version: 1,
58
- tone: {
59
- preset: "default",
60
- },
61
- knowledgeCaptureLevel: 2,
62
- spaceContextLevel: 3,
63
- };
64
-
@@ -1,26 +0,0 @@
1
- import type { PageSkillMetadata } from "./skillDocProtocol";
2
- import type { SpaceContent } from "../../app/types";
3
-
4
- export type SkillSummaryMarker = NonNullable<SpaceContent["skillSummary"]>;
5
-
6
- export const buildSkillSummaryMarker = (
7
- meta?: PageSkillMetadata | null
8
- ): SkillSummaryMarker | null => {
9
- const skillConfig = meta?.skillConfig;
10
- if (meta?.kind !== "skill" && !skillConfig) {
11
- return null;
12
- }
13
-
14
- return {
15
- isSkill: true,
16
- ...(skillConfig?.id ? { skillId: skillConfig.id } : {}),
17
- ...(skillConfig?.name ? { name: skillConfig.name } : {}),
18
- ...(skillConfig?.description ? { description: skillConfig.description } : {}),
19
- ...(skillConfig?.toolNames?.length ? { toolNames: skillConfig.toolNames } : {}),
20
- ...(skillConfig?.triggerMode ? { triggerMode: skillConfig.triggerMode } : {}),
21
- };
22
- };
23
-
24
- export const isSkillSummaryMarker = (
25
- value: SpaceContent["skillSummary"] | undefined | null
26
- ): value is SkillSummaryMarker => Boolean(value?.isSkill);
package/app/types.ts DELETED
@@ -1,358 +0,0 @@
1
- // packages/app/types.ts
2
- import type { UiOption, OpenAIImageContent } from "../chat/messages/types";
3
- import { DataType } from "../create/types";
4
- import type {
5
- AgentBasePolicy,
6
- DialogPolicyState,
7
- } from "../ai/policy/types";
8
-
9
- export type ULID = string;
10
-
11
- export type DialogRuntimeController =
12
- | "request"
13
- | "scheduler"
14
- | "server-supervisor"
15
- | "external-supervisor";
16
-
17
- export type DialogRuntimeProfile = "autonomous";
18
-
19
- export interface DialogRuntimeBinding {
20
- version: 1;
21
- /** 当前 product runtime 的 tenant 边界;本地模型 watchdog 不属于这里。 */
22
- tenantUserId?: string | null;
23
- agentKey: string;
24
- /** 当前长期 runtime 的 durable anchor;现阶段直接复用 dialog。 */
25
- runtimeAnchorDialogId: string;
26
- controller: DialogRuntimeController;
27
- triggerType?: "user" | "api" | "localhost" | "scheduled_run";
28
- executionMode?: "foreground" | "background";
29
- runtimeProfile?: DialogRuntimeProfile;
30
- spaceId?: string;
31
- category?: string;
32
- /** Effective runtime/tool policy snapshot for this dialog run. */
33
- runtimeToolPolicySnapshot?: Record<string, unknown>;
34
- /** Workspace lease/session used by machine or workspace-backed tools. */
35
- workspaceLease?: Record<string, unknown>;
36
- }
37
-
38
- export interface AgentRuntimeBinding {
39
- machineId?: string | null;
40
- ownerUserId?: string | null;
41
- requiredCapabilities?: string[] | null;
42
- runtimeToolPolicy?: Record<string, unknown> | null;
43
- }
44
-
45
- export interface DialogGoalState {
46
- objective: string;
47
- status: "active" | "complete";
48
- tokenBudget?: number;
49
- createdAt: number;
50
- completedAt?: number;
51
- }
52
-
53
- export interface DialogSubjectRef {
54
- kind: "table-row" | "page" | "dialog" | "asset" | "external" | string;
55
- id: string;
56
- role?: "subject" | "parent" | "work-item" | "artifact" | string;
57
- }
58
-
59
- export interface DialogConfig {
60
- id: string; // 对话的唯一标识符/路径
61
- type: DataType.DIALOG; // 数据类型标记
62
- title: string; // 对话标题
63
- cybots: string[]; // 兼容字段:当前对话参与的 agent ID 列表
64
- primaryAgentKey?: string;
65
- taskLabel?: string;
66
- tags?: string[];
67
- createdAt: string; // 创建时间戳
68
- updatedAt: string; // 最后更新时间戳
69
- dbKey?: string;
70
- spaceId?: string;
71
- category?: string;
72
-
73
- // --- 上下文压缩 ---
74
- summary?: string; // 对话摘要(单层覆盖式)
75
- summarizedBeforeId?: string; // 摘要覆盖到哪条消息 ID
76
- proactiveSummary?: string; // 主动工作摘要(不裁剪原始消息,供被动压缩消费)
77
- proactiveSummaryBeforeId?: string; // 主动工作摘要覆盖到哪条消息 ID
78
- compressionCount?: number; // 压缩次数(用于极端情况提示)
79
- referenceKeys?: string[]; // 消息中引用过的 pageKey/dialogKey(替代 historyKeys 扫描)
80
- inheritedFromDialogKey?: string; // 若从旧对话开启,记录来源对话 key 以便刷新后仍可提示
81
- inheritedFromDialogTitle?: string; // 来源对话标题快照,用于 UI 提示
82
- summaryPending?: boolean; // 摘要任务是否挂起(因快速切换等原因)
83
- inputTokens?: number;
84
- outputTokens?: number;
85
- maxTokens?: number; // 此对话最大回复 token 数,覆盖 agent 默认值
86
-
87
- // --- 执行模式(API/后台/定时场景扩展,前台对话不填) ---
88
- /** 谁触发的:user=用户前台输入 api=外部API调用 localhost=本机调用 scheduled_run=定时任务运行 */
89
- triggerType?: "user" | "api" | "localhost" | "scheduled_run";
90
- /** foreground=用户等结果(流式) background=后台静默执行 */
91
- executionMode?: "foreground" | "background";
92
- /** 仅 background/scheduled 场景有意义 */
93
- status?: "pending" | "running" | "done" | "failed" | "cancelled";
94
- scheduledAt?: number; // 定时任务预定执行时间戳
95
- startedAt?: number;
96
- finishedAt?: number;
97
- durationMs?: number;
98
- toolCallCount?: number;
99
- totalCost?: number;
100
- cliSessionId?: string;
101
- /** multi-agent: 当前 dialog 由哪个父 dialog 发起 */
102
- parentDialogId?: string;
103
- /** multi-agent: 这棵 dialog 执行树的根 dialog,便于查询 fanout */
104
- rootDialogId?: string;
105
- /** 当前 dialog 关联的业务对象;保持行业中立,不只服务任务表 */
106
- subjectRefs?: DialogSubjectRef[];
107
- /** 定时任务运行产生的对话归属的任务 key */
108
- parentTaskKey?: string;
109
- /** 定时任务去重 key */
110
- idempotencyKey?: string;
111
- /** cron 表达式,用于重复执行,如 "0 2 * * *" */
112
- schedule?: string;
113
- /** 定时任务执行的指令(不同于对话内容,是固定的任务描述) */
114
- taskPrompt?: string;
115
- policyState?: DialogPolicyState;
116
- runtimeBinding?: DialogRuntimeBinding;
117
- goal?: DialogGoalState;
118
- }
119
-
120
- export interface ScheduledTaskConfig {
121
- id: string;
122
- dbKey: string;
123
- type: DataType.TASK;
124
- title: string;
125
- agentKey: string;
126
- cybots: string[];
127
- createdBy: string;
128
- createdAt: string;
129
- updatedAt: string;
130
- spaceId?: string;
131
- status: "active" | "paused" | "cancelled";
132
- runStatus?: "idle" | "running" | "done" | "failed";
133
- schedule: string;
134
- taskPrompt: string;
135
- nextRunAt: number;
136
- lastRunAt?: number;
137
- lastRunDialogKey?: string;
138
- lastRunError?: string;
139
- runDialogKeys?: string[];
140
- }
141
- export type ReferenceItem = {
142
- dbKey: string;
143
- title: string;
144
- type: "knowledge" | "instruction";
145
- };
146
-
147
-
148
- export interface AgentGreetingMenuItem extends UiOption {
149
- /** 以后如果想在 UI 上做分组,可以用 group;现在先不实现 UI */
150
- group?: string;
151
- }
152
-
153
-
154
- /**
155
- * Agent 的富 greeting:
156
- * - text: 打招呼文案(markdown)
157
- * - menu: 初始菜单项(会显示成第一条消息下方的按钮)
158
- */
159
- export interface AgentGreetingConfig {
160
- text?: string;
161
- menu?: AgentGreetingMenuItem[];
162
- }
163
-
164
-
165
-
166
- export type PublicImageAgentMode = "generate" | "edit" | "continuous";
167
-
168
- export interface Agent {
169
- /**
170
- * Image workflow mode for this agent.
171
- * - generate: text-to-image
172
- * - edit: image editing
173
- * - continuous: multi-step/interactive image workflows
174
- */
175
- imageWorkflow?: PublicImageAgentMode;
176
- // --- 你已有的所有字段 ---
177
- provider: string;
178
- model: string;
179
- imageModel?: string;
180
- /** 执行来源:platform=平台API custom=自定义API/本地 cli=命令行工具 */
181
- apiSource?: "platform" | "custom" | "cli";
182
- /** cli 时指定使用哪个 CLI 工具。CLI 可复用 prompt/model/最近文本历史,但不走本地 tool 协议。 */
183
- cliProvider?: "copilot" | "gemini" | "codex" | "claude" | "agy";
184
- prompt?: string;
185
- name?: string;
186
- [key: string]: any;
187
- tools?: string[];
188
- userId: string;
189
- useServerProxy: boolean;
190
- apiKey?: string;
191
- apiKeyFromAgentKey?: string;
192
- customProviderUrl?: string;
193
- temperature?: number;
194
- top_p?: number;
195
- frequency_penalty?: number;
196
- presence_penalty?: number;
197
- max_tokens?: number;
198
- reasoning_effort?: string;
199
- enableThinking?: boolean;
200
- thinkingBudget?: number;
201
- updatedAt: string;
202
- createdAt: number;
203
- categoryId?: string;
204
- spaceId?: string;
205
- references?: ReferenceItem[];
206
- tags?: string[];
207
- tokenCount?: number;
208
- messageCount?: number;
209
- dialogCount?: number;
210
- outputPrice?: number;
211
- inputPrice?: number;
212
- introduction?: string;
213
- cover?: string;
214
- greeting?: string | AgentGreetingConfig; // ✅ 这里改成联合类型
215
- isPublic: boolean;
216
- endpointKey?: string;
217
-
218
-
219
- imageConfig?: {
220
- enabled?: boolean;
221
- aspectRatio?:
222
- | "1:1"
223
- | "2:3"
224
- | "3:2"
225
- | "3:4"
226
- | "4:3"
227
- | "4:5"
228
- | "5:4"
229
- | "9:16"
230
- | "16:9"
231
- | "21:9";
232
- imageSize?: "1K" | "2K" | "4K";
233
- forceModalities?: Array<"text" | "image">;
234
- };
235
-
236
- whitelist?: string[];
237
-
238
- // Cross-Space Context: 关联的其他 Space ID 列表
239
- // Agent 可以访问这些 Space 的内容作为粗略上下文
240
- linkedSpaces?: string[];
241
- basePolicy?: AgentBasePolicy;
242
- runtimeBinding?: AgentRuntimeBinding | null;
243
- }
244
-
245
-
246
-
247
- // --- 内容相关 (核心修改处) ---
248
-
249
- export interface SpaceContent {
250
- title: string;
251
- type: ContentType;
252
- contentKey: string; // 唯一标识符 (通常是 dbKey)
253
- fileCategory?: FileCategory;
254
- mimeType?: string;
255
- fileSize?: number;
256
- originalName?: string;
257
-
258
- // --- 修改: categoryId 变为可选 ---
259
- categoryId?: string; // 属性不存在或值为 undefined 代表未分类
260
-
261
- pinned: boolean;
262
- createdAt: number; // 时间戳 (number)
263
- updatedAt: number; // 时间戳 (number)
264
- order?: number; // 分类内排序
265
- tags?: string[]; // 保留 tags 字段
266
- triggerType?: string;
267
- skillSummary?: {
268
- isSkill: true;
269
- skillId?: string;
270
- name?: string;
271
- description?: string;
272
- toolNames?: string[];
273
- triggerMode?: "explicit" | "required" | "recommended";
274
- } | null;
275
- } // --- 主数据结构 (SpaceData 保持不变) ---
276
-
277
- export interface SpaceData {
278
- id: ULID;
279
- name: string;
280
- description: string;
281
- ownerId: string;
282
- visibility: SpaceVisibility;
283
- members: string[]; // userId 列表
284
- categories: Categories;
285
- contents: Contents;
286
- createdAt: number;
287
- updatedAt: number;
288
- }
289
- export enum ContentType {
290
- DIALOG = "dialog",
291
- DOC = "page",
292
- FILE = "file",
293
- IMAGE = "image",
294
- AGENT = "agent",
295
- APP = "app",
296
- TASK = "task",
297
- } // --- 枚举 (保持不变) ---
298
- export type FileCategory =
299
- | "image"
300
- | "document"
301
- | "video"
302
- | "audio"
303
- | "other";
304
- export enum SpaceVisibility {
305
- PRIVATE = "private",
306
- PUBLIC = "public",
307
- }
308
- export enum MemberRole {
309
- OWNER = "owner",
310
- ADMIN = "admin",
311
- MEMBER = "member",
312
- GUEST = "guest",
313
- }
314
- export type Categories = Record<string, Category | null>; // --- 分类相关 (Category, Categories 保持不变) ---
315
- export interface Category {
316
- name: string;
317
- order: number;
318
- updatedAt: number;
319
- } // --- 成员相关 (SpaceMember, SpaceMemberWithSpaceInfo 保持不变) ---
320
-
321
- export interface SpaceMember {
322
- role: MemberRole;
323
- joinedAt: number;
324
- updatedAt?: number;
325
- userId: string;
326
- spaceId: string;
327
- } // Contents 类型保持不变 (Record<string, SpaceContent | null>)
328
- export type Contents = Record<string, SpaceContent | null>;
329
- export interface SpaceMemberWithSpaceInfo {
330
- role: MemberRole;
331
- joinedAt: number;
332
- memberUpdatedAt?: number;
333
- spaceId: string;
334
- spaceName: string;
335
- ownerId: string;
336
- visibility: SpaceVisibility;
337
- spaceCreatedAt: number;
338
- spaceUpdatedAt: number;
339
- type?: DataType;
340
- }
341
-
342
- type MessageContentPartText = { type: "text"; text: string };
343
- type MessageContentPartImageUrl = OpenAIImageContent;
344
-
345
- type MessageContentPart = MessageContentPartText | MessageContentPartImageUrl;
346
-
347
- export interface Message {
348
- id?: string;
349
- role: "user" | "assistant" | "system" | "tool" | "developer";
350
- content: string | MessageContentPart[];
351
- name?: string;
352
- tool_calls?: any;
353
- tool_call_id?: string;
354
- userId?: string;
355
- }
356
-
357
- // Share types re-exported from share/types
358
- export type { ShareType, SharedObject, ShareMeta, ShareSummary } from "../share/types";
package/build.ts DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { buildPublishArtifact } from "./buildPublish";
4
- import { dirname, join } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const CLI_DIR = dirname(fileURLToPath(import.meta.url));
8
- const DIST_DIR = join(CLI_DIR, "dist");
9
-
10
- console.log("Building publish artifact...");
11
- console.log("Source:", CLI_DIR);
12
- console.log("Dist:", DIST_DIR);
13
-
14
- await buildPublishArtifact(CLI_DIR, DIST_DIR);
15
-
16
- console.log("Build complete! Artifact at:", DIST_DIR);
package/buildPublish.ts DELETED
@@ -1,138 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import {
4
- buildPublishArtifactAssembly,
5
- inlineWorkspaceDependencies,
6
- } from "./buildPublishArtifactAssembly";
7
- import {
8
- collectTypeScriptSourceFiles,
9
- collectWorkspaceDependencies,
10
- extractExternalImports,
11
- rewriteCrossPackageImports,
12
- } from "./buildPublishImportAnalysis";
13
- import { buildPublishManifest } from "./publishPackage";
14
-
15
- /**
16
- * Build a publish-safe CLI artifact in the dist directory.
17
- *
18
- * This function:
19
- * 1. Creates a dist directory
20
- * 2. Copies source files specified in package.json "files" array
21
- * 3. Generates a publish-safe package.json (no workspace deps)
22
- * 4. Inlines workspace dependencies from monorepo packages
23
- *
24
- * The output can be published to npm and installed outside the monorepo.
25
- *
26
- * @param sourceDir - The CLI package source directory (packages/cli)
27
- * @param distDir - The output directory (packages/cli/dist)
28
- */
29
- export async function buildPublishArtifact(
30
- sourceDir: string,
31
- distDir: string
32
- ): Promise<void> {
33
- const pkgPath = join(sourceDir, "package.json");
34
- if (!existsSync(pkgPath)) {
35
- throw new Error(`package.json not found at ${pkgPath}`);
36
- }
37
-
38
- const sourceManifest = JSON.parse(readFileSync(pkgPath, "utf8"));
39
- const filesToCopy = sourceManifest.files || [];
40
- const warn = (message: string, error?: unknown): void => {
41
- if (error === undefined) {
42
- console.warn(message);
43
- return;
44
- }
45
- console.warn(message, error);
46
- };
47
-
48
- const {
49
- resolvedFilesToCopy,
50
- inlinedDeps,
51
- inlinedFiles = [],
52
- externalDeps,
53
- } = await buildPublishArtifactAssembly({
54
- sourceDir,
55
- distDir,
56
- filesToCopy,
57
- extractExternalImports,
58
- rewriteCrossPackageImports,
59
- collectWorkspaceDependencies: (entrySourceDir, resolvedFiles) =>
60
- collectWorkspaceDependencies(entrySourceDir, sourceManifest, resolvedFiles),
61
- inlineWorkspaceDependencies,
62
- warn,
63
- });
64
-
65
- const publishManifest = buildPublishManifest(sourceManifest);
66
- const repoRoot = join(sourceDir, "..", "..");
67
- const rootManifest = existsSync(join(repoRoot, "package.json"))
68
- ? JSON.parse(readFileSync(join(repoRoot, "package.json"), "utf8"))
69
- : {};
70
- const cliExternalDeps = discoverExternalImportsFromCliSourceFiles(
71
- sourceDir,
72
- resolvedFilesToCopy,
73
- rootManifest
74
- );
75
-
76
- if (inlinedFiles.length > 0) {
77
- publishManifest.files = Array.from(new Set([...resolvedFilesToCopy, ...inlinedFiles]));
78
- } else if (inlinedDeps.length > 0) {
79
- publishManifest.files = Array.from(new Set(resolvedFilesToCopy));
80
- for (const dep of inlinedDeps) {
81
- publishManifest.files.push(`${dep}/**/*.ts`);
82
- }
83
- } else {
84
- publishManifest.files = Array.from(new Set(resolvedFilesToCopy));
85
- }
86
-
87
- if (Object.keys(externalDeps).length > 0) {
88
- publishManifest.dependencies = publishManifest.dependencies || {};
89
- for (const [name, version] of Object.entries(externalDeps)) {
90
- if (!publishManifest.dependencies[name]) {
91
- publishManifest.dependencies[name] = version;
92
- }
93
- }
94
- }
95
-
96
- if (Object.keys(cliExternalDeps).length > 0) {
97
- publishManifest.dependencies = publishManifest.dependencies || {};
98
- for (const [name, version] of Object.entries(cliExternalDeps)) {
99
- if (!publishManifest.dependencies[name]) {
100
- publishManifest.dependencies[name] = version;
101
- }
102
- }
103
- }
104
-
105
- writeFileSync(
106
- join(distDir, "package.json"),
107
- JSON.stringify(publishManifest, null, 2) + "\n"
108
- );
109
- }
110
-
111
- function discoverExternalImportsFromCliSourceFiles(
112
- sourceDir: string,
113
- filesToCopy: string[],
114
- rootManifest: Record<string, any>
115
- ): Record<string, string> {
116
- const rootDeps: Record<string, string> = {};
117
- if (rootManifest.dependencies) {
118
- for (const [name, version] of Object.entries(rootManifest.dependencies)) {
119
- if (typeof version === "string" && !version.startsWith("workspace:")) {
120
- rootDeps[name] = version;
121
- }
122
- }
123
- }
124
-
125
- const externalDeps: Record<string, string> = {};
126
- for (const filePath of collectTypeScriptSourceFiles(sourceDir, filesToCopy)) {
127
- const content = readFileSync(filePath, "utf8");
128
- for (const importName of extractExternalImports(content)) {
129
- if (rootDeps[importName]) {
130
- externalDeps[importName] = rootDeps[importName];
131
- }
132
- }
133
- }
134
-
135
- return externalDeps;
136
- }
137
-
138
- export { rewriteCrossPackageImports } from "./buildPublishImportAnalysis";