nolo-cli 0.1.32 → 0.1.33

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 (230) hide show
  1. package/README.md +0 -6
  2. package/agent-runtime/agentRecordConfig.ts +2 -0
  3. package/agent-runtime/hostAdapter.ts +1 -0
  4. package/agent-runtime/index.ts +0 -21
  5. package/agent-runtime/localToolPolicy.ts +6 -13
  6. package/agent-runtime/localWorkspaceTools.ts +30 -333
  7. package/agent-runtime/platformChatProvider.ts +1 -4
  8. package/agent-runtime/runtimeToolPolicy.ts +47 -32
  9. package/agentAliases.ts +14 -83
  10. package/agentCommandSupport.ts +3 -6
  11. package/agentInternalCommandEntries.ts +2 -13
  12. package/agentListCommands.ts +19 -28
  13. package/agentMachineCommands.ts +40 -336
  14. package/agentPullCommand.ts +36 -56
  15. package/agentRecordCommands.ts +3 -5
  16. package/agentRecordHelpers.ts +22 -189
  17. package/agentRunCommand.ts +438 -107
  18. package/agentRuntimeLocal.ts +0 -10
  19. package/ai/agent/cliExecutor.ts +19 -323
  20. package/authCommands.ts +2 -36
  21. package/cli/agentAliases.ts +14 -83
  22. package/cli/agentCommandSupport.ts +3 -6
  23. package/cli/agentInternalCommandEntries.ts +2 -13
  24. package/cli/agentListCommands.ts +19 -28
  25. package/cli/agentMachineCommands.ts +40 -336
  26. package/cli/agentPullCommand.ts +36 -56
  27. package/cli/agentRecordCommands.ts +3 -5
  28. package/cli/agentRecordHelpers.ts +22 -189
  29. package/cli/agentRunCommand.ts +438 -107
  30. package/cli/agentRuntimeLocal.ts +0 -10
  31. package/cli/authCommands.ts +2 -36
  32. package/cli/cliEnvHelpers.ts +21 -162
  33. package/cli/client/agentRun.ts +853 -57
  34. package/cli/client/localRuntimeAdapter.ts +22 -159
  35. package/cli/client/streamingOutput.ts +3 -1
  36. package/cli/client/taskRunPrompt.ts +24 -7
  37. package/cli/commandRegistry.ts +2 -3
  38. package/cli/connectorRunArtifact.ts +10 -34
  39. package/cli/connectorWebSocketTarget.ts +6 -10
  40. package/cli/internalCommandEntries.ts +0 -8
  41. package/cli/localRuntimeDb.ts +2 -39
  42. package/cli/machineCommands.ts +189 -190
  43. package/cli/machineDaemonCommands.ts +165 -9
  44. package/cli/machineHeartbeatCommands.ts +2 -1
  45. package/cli/machineStatusCommands.ts +13 -5
  46. package/cli/machineWatchCommands.ts +1 -1
  47. package/cli/machineWsRunDispatch.ts +14 -48
  48. package/cli/machineWsSession.ts +0 -2
  49. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  50. package/cli/runtimeDoctorCommands.ts +69 -18
  51. package/cli/scriptCommandEntries.ts +45 -5
  52. package/cli/tableCommands.ts +133 -33
  53. package/cli/taskRunCommand.ts +211 -16
  54. package/cli/tui/session.ts +372 -43
  55. package/cli/workflowInternalCommandEntries.ts +0 -20
  56. package/cliEnvHelpers.ts +21 -162
  57. package/client/agentConfigResolver.test.ts +2 -0
  58. package/client/agentRun.test.ts +12 -208
  59. package/client/agentRun.ts +853 -57
  60. package/client/localRuntimeAdapter.test.ts +9 -168
  61. package/client/localRuntimeAdapter.ts +22 -159
  62. package/client/localToolPolicy.test.ts +4 -28
  63. package/client/streamingOutput.ts +3 -1
  64. package/client/taskRunPrompt.ts +24 -7
  65. package/commandRegistry.ts +2 -3
  66. package/connectorRunArtifact.ts +10 -34
  67. package/connectorWebSocketTarget.ts +6 -10
  68. package/database/server/db.ts +34 -15
  69. package/internalCommandEntries.ts +0 -8
  70. package/localRuntimeDb.ts +2 -39
  71. package/machineCommands.ts +189 -190
  72. package/machineDaemonCommands.ts +165 -9
  73. package/machineHeartbeatCommands.ts +2 -1
  74. package/machineStatusCommands.ts +13 -5
  75. package/machineWatchCommands.ts +1 -1
  76. package/machineWsRunDispatch.ts +14 -48
  77. package/machineWsSession.ts +0 -2
  78. package/offlineMarxistsAgentCommand.ts +314 -0
  79. package/package.json +49 -193
  80. package/runtimeDoctorCommands.ts +69 -18
  81. package/scriptCommandEntries.ts +45 -5
  82. package/tableCommands.ts +133 -33
  83. package/taskRunCommand.ts +211 -16
  84. package/tui/session.ts +372 -43
  85. package/workflowInternalCommandEntries.ts +0 -20
  86. package/agent-runtime/dialogStatus.ts +0 -139
  87. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  88. package/agentCreateCustomCommands.ts +0 -278
  89. package/agentDialogsCommands.ts +0 -227
  90. package/agentDoctorCommands.ts +0 -203
  91. package/agentRunLocalWorkspace.ts +0 -182
  92. package/agentRunParsing.ts +0 -298
  93. package/agentSuperviseCommands.ts +0 -8
  94. package/agentUnpublishCommands.ts +0 -113
  95. package/ai/agent/agentRunDialogLineage.ts +0 -56
  96. package/ai/policy/types.ts +0 -64
  97. package/ai/skills/skillSummaryMarker.ts +0 -26
  98. package/app/types.ts +0 -358
  99. package/build.ts +0 -16
  100. package/buildPublish.ts +0 -138
  101. package/buildPublishArtifactAssembly.ts +0 -724
  102. package/buildPublishImportAnalysis.ts +0 -242
  103. package/chat/messages/fetchMessages.ts +0 -84
  104. package/chat/messages/types.ts +0 -185
  105. package/cli/agentCreateCustomCommands.ts +0 -278
  106. package/cli/agentDialogsCommands.ts +0 -227
  107. package/cli/agentDoctorCommands.ts +0 -203
  108. package/cli/agentRunLocalWorkspace.ts +0 -182
  109. package/cli/agentRunParsing.ts +0 -298
  110. package/cli/agentSuperviseCommands.ts +0 -8
  111. package/cli/agentUnpublishCommands.ts +0 -113
  112. package/cli/buildPublish.ts +0 -138
  113. package/cli/buildPublishArtifactAssembly.ts +0 -724
  114. package/cli/buildPublishImportAnalysis.ts +0 -242
  115. package/cli/cliIoTypes.ts +0 -3
  116. package/cli/cliRuntimeDoctorReport.ts +0 -193
  117. package/cli/client/agentRunInput.ts +0 -10
  118. package/cli/client/agentRunLocalExecution.ts +0 -124
  119. package/cli/client/agentRunLocalExecutor.ts +0 -179
  120. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  121. package/cli/client/agentRunServerTransport.ts +0 -397
  122. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  123. package/cli/customCodingAgentFlow.ts +0 -208
  124. package/cli/customCodingAgentRecord.ts +0 -179
  125. package/cli/dialogDataAccess.ts +0 -186
  126. package/cli/dialogInternalCommandEntries.ts +0 -11
  127. package/cli/dialogReadCommands.ts +0 -180
  128. package/cli/dialogReadHelpers.ts +0 -226
  129. package/cli/dialogStatusCommands.ts +0 -123
  130. package/cli/docInternalCommandEntries.ts +0 -20
  131. package/cli/hybridReadHelpers.ts +0 -109
  132. package/cli/machineCommandPrompts.ts +0 -79
  133. package/cli/machineCommandResolution.ts +0 -43
  134. package/cli/noloReadBridgePrompt.ts +0 -16
  135. package/cli/pageCreateCommands.ts +0 -219
  136. package/cli/pageDeleteCommands.ts +0 -167
  137. package/cli/pageReadCommands.ts +0 -151
  138. package/cli/pageUpdateCommands.ts +0 -249
  139. package/cli/pageWriteHelpers.ts +0 -209
  140. package/cli/publishPackage.ts +0 -36
  141. package/cli/runtimeInternalCommandEntries.ts +0 -15
  142. package/cli/runtimePassthroughCommands.ts +0 -22
  143. package/cli/scriptPassthroughHelpers.ts +0 -28
  144. package/cli/secretScanHelpers.ts +0 -31
  145. package/cli/spaceAttachCommands.ts +0 -134
  146. package/cli/spaceCategoryCommands.ts +0 -263
  147. package/cli/spaceCommands.ts +0 -295
  148. package/cli/spaceDeleteCommands.ts +0 -312
  149. package/cli/spaceInternalCommandEntries.ts +0 -21
  150. package/cli/spaceMutationHelpers.ts +0 -135
  151. package/cli/spaceReadCommands.ts +0 -323
  152. package/cli/tableDataOutput.ts +0 -41
  153. package/cli/tableDataSafety.ts +0 -26
  154. package/cli/tableMetaCommands.ts +0 -307
  155. package/cli/tableMutationCommands.ts +0 -266
  156. package/cli/tableQueryParsing.ts +0 -90
  157. package/cli/tableQueryRequest.ts +0 -53
  158. package/cli/taskRunActions.ts +0 -122
  159. package/cli/taskRunParsing.ts +0 -86
  160. package/cli/taskRunPromptShared.ts +0 -55
  161. package/cli/tui/tuiCatalog.ts +0 -22
  162. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  163. package/cli/tui/tuiPresentation.ts +0 -146
  164. package/cliIoTypes.ts +0 -3
  165. package/cliRuntimeDoctorReport.ts +0 -193
  166. package/client/agentRunInput.ts +0 -10
  167. package/client/agentRunLocalExecution.test.ts +0 -123
  168. package/client/agentRunLocalExecution.ts +0 -124
  169. package/client/agentRunLocalExecutor.ts +0 -179
  170. package/client/agentRunRuntimeSelection.test.ts +0 -159
  171. package/client/agentRunRuntimeSelection.ts +0 -145
  172. package/client/agentRunServerTransport.ts +0 -397
  173. package/client/agentRunTaskRunRecorder.ts +0 -176
  174. package/connector-experimental/daemonLauncher.ts +0 -223
  175. package/create/space/spaceKeys.ts +0 -65
  176. package/create/types.ts +0 -21
  177. package/customCodingAgentFlow.ts +0 -208
  178. package/customCodingAgentRecord.ts +0 -179
  179. package/database/keys.ts +0 -765
  180. package/database/server/authorityStoreTypes.ts +0 -31
  181. package/database/server/legacyServerDb.ts +0 -58
  182. package/database/server/levelAuthorityStore.ts +0 -75
  183. package/database/server/memoryAuthorityStore.ts +0 -133
  184. package/database/server/serverStoreFactory.ts +0 -124
  185. package/database/tombstones.ts +0 -52
  186. package/database/utils/ulid.ts +0 -1
  187. package/dialogDataAccess.ts +0 -186
  188. package/dialogInternalCommandEntries.ts +0 -11
  189. package/dialogReadCommands.ts +0 -180
  190. package/dialogReadHelpers.ts +0 -226
  191. package/dialogStatusCommands.ts +0 -123
  192. package/docInternalCommandEntries.ts +0 -20
  193. package/hybridReadHelpers.ts +0 -109
  194. package/machineCommandPrompts.ts +0 -79
  195. package/machineCommandResolution.ts +0 -43
  196. package/noloReadBridgePrompt.ts +0 -16
  197. package/pageCreateCommands.ts +0 -219
  198. package/pageDeleteCommands.ts +0 -167
  199. package/pageReadCommands.ts +0 -151
  200. package/pageUpdateCommands.ts +0 -249
  201. package/pageWriteHelpers.ts +0 -209
  202. package/publishPackage.ts +0 -36
  203. package/runtimeInternalCommandEntries.ts +0 -15
  204. package/runtimePassthroughCommands.ts +0 -22
  205. package/scriptPassthroughHelpers.ts +0 -28
  206. package/secretScanHelpers.ts +0 -31
  207. package/share/helpers.ts +0 -302
  208. package/share/keys.ts +0 -243
  209. package/share/types.ts +0 -100
  210. package/spaceAttachCommands.ts +0 -134
  211. package/spaceCategoryCommands.ts +0 -263
  212. package/spaceCommands.ts +0 -295
  213. package/spaceDeleteCommands.ts +0 -312
  214. package/spaceInternalCommandEntries.ts +0 -21
  215. package/spaceMutationHelpers.ts +0 -135
  216. package/spaceReadCommands.ts +0 -323
  217. package/tableDataOutput.ts +0 -41
  218. package/tableDataSafety.ts +0 -26
  219. package/tableMetaCommands.ts +0 -307
  220. package/tableMutationCommands.ts +0 -266
  221. package/tableQueryParsing.ts +0 -90
  222. package/tableQueryRequest.ts +0 -53
  223. package/taskRunActions.ts +0 -122
  224. package/taskRunParsing.ts +0 -86
  225. package/taskRunPromptShared.ts +0 -55
  226. package/tui/tuiCatalog.ts +0 -22
  227. package/tui/tuiCommandInterpreter.test.ts +0 -169
  228. package/tui/tuiCommandInterpreter.ts +0 -253
  229. package/tui/tuiPresentation.test.ts +0 -154
  230. 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";