interaqt 0.6.1 → 0.6.2
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/agent/agentspace/knowledge/generator/api-reference.md +14 -9
- package/agent/agentspace/knowledge/generator/test-implementation.md +18 -6
- package/agent/agentspace/knowledge/usage/05-interactions.md +5 -5
- package/agent/agentspace/knowledge/usage/13-testing.md +5 -5
- package/agent/agentspace/knowledge/usage/14-api-reference.md +16 -8
- package/agent/agentspace/prompt/requirement_analysis_refactor.md +34 -0
- package/dist/index.js +219 -239
- package/dist/index.js.map +1 -1
- package/dist/runtime/Controller.d.ts +3 -4
- package/dist/runtime/Controller.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -2807,11 +2807,17 @@ Initialize system.
|
|
|
2807
2807
|
await controller.setup(true) // Create database tables
|
|
2808
2808
|
```
|
|
2809
2809
|
|
|
2810
|
-
#### callInteraction(interactionName: string, args: InteractionEventArgs)
|
|
2811
|
-
Call interaction.
|
|
2810
|
+
#### callInteraction(interactionName: string, args: InteractionEventArgs, activityName?: string, activityId?: string)
|
|
2811
|
+
Call interaction or activity interaction.
|
|
2812
2812
|
|
|
2813
2813
|
**Note about ignorePermission**: When `controller.ignorePermission` is set to `true`, this method will bypass all condition checks, user validation, and payload validation defined in the interaction.
|
|
2814
2814
|
|
|
2815
|
+
**Parameters**
|
|
2816
|
+
- `interactionName`: The name of the interaction to call
|
|
2817
|
+
- `args`: The interaction event arguments containing user and payload
|
|
2818
|
+
- `activityName` (optional): The name of the activity when calling an activity interaction
|
|
2819
|
+
- `activityId` (optional): The ID of the activity instance when calling an activity interaction
|
|
2820
|
+
|
|
2815
2821
|
**Return Type**
|
|
2816
2822
|
```typescript
|
|
2817
2823
|
type InteractionCallResponse = {
|
|
@@ -2842,7 +2848,7 @@ type InteractionCallResponse = {
|
|
|
2842
2848
|
}
|
|
2843
2849
|
```
|
|
2844
2850
|
|
|
2845
|
-
**Example**
|
|
2851
|
+
**Example - Regular Interaction**
|
|
2846
2852
|
```typescript
|
|
2847
2853
|
const result = await controller.callInteraction('createPost', {
|
|
2848
2854
|
user: { id: 'user1' },
|
|
@@ -2864,14 +2870,13 @@ if (result.sideEffects?.emailNotification?.error) {
|
|
|
2864
2870
|
}
|
|
2865
2871
|
```
|
|
2866
2872
|
|
|
2867
|
-
|
|
2868
|
-
Call interaction within activity.
|
|
2873
|
+
**Example - Activity Interaction**
|
|
2869
2874
|
```typescript
|
|
2870
|
-
const result = await controller.
|
|
2871
|
-
'OrderProcess',
|
|
2875
|
+
const result = await controller.callInteraction(
|
|
2872
2876
|
'confirmOrder',
|
|
2873
|
-
'
|
|
2874
|
-
|
|
2877
|
+
{ user: { id: 'user1' }, payload: { orderData: {...} } },
|
|
2878
|
+
'OrderProcess',
|
|
2879
|
+
'activity-instance-1'
|
|
2875
2880
|
)
|
|
2876
2881
|
```
|
|
2877
2882
|
|
|
@@ -35,7 +35,19 @@ expect(result.error).toBeUndefined()
|
|
|
35
35
|
|
|
36
36
|
## callInteraction Return Value
|
|
37
37
|
|
|
38
|
-
The `controller.callInteraction()` method
|
|
38
|
+
The `controller.callInteraction()` method is used for both regular interactions and activity interactions.
|
|
39
|
+
|
|
40
|
+
**Method Signature:**
|
|
41
|
+
```typescript
|
|
42
|
+
callInteraction(
|
|
43
|
+
interactionName: string,
|
|
44
|
+
args: InteractionEventArgs,
|
|
45
|
+
activityName?: string, // Optional: for activity interactions
|
|
46
|
+
activityId?: string // Optional: for activity interactions
|
|
47
|
+
): Promise<InteractionCallResponse>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The method returns a `InteractionCallResponse` object with the following structure:
|
|
39
51
|
|
|
40
52
|
```typescript
|
|
41
53
|
type InteractionCallResponse = {
|
|
@@ -232,11 +244,11 @@ expect(publishResult.error).toBeUndefined()
|
|
|
232
244
|
expect(publishResult.sideEffects?.emailNotification?.result).toBe('sent')
|
|
233
245
|
|
|
234
246
|
// 4. Activity interactions return activityId
|
|
235
|
-
const activityResult = await controller.
|
|
236
|
-
'
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
const activityResult = await controller.callInteraction(
|
|
248
|
+
'StartApproval',
|
|
249
|
+
{...},
|
|
250
|
+
'ApprovalWorkflow',
|
|
251
|
+
undefined
|
|
240
252
|
)
|
|
241
253
|
const activityId = activityResult.context?.activityId
|
|
242
254
|
```
|
|
@@ -1205,20 +1205,20 @@ if (createPostInteraction) {
|
|
|
1205
1205
|
|
|
1206
1206
|
```javascript
|
|
1207
1207
|
// Execute interaction as part of an activity
|
|
1208
|
-
const result = await controller.
|
|
1209
|
-
'OrderProcess', // activity name
|
|
1208
|
+
const result = await controller.callInteraction(
|
|
1210
1209
|
'processPayment', // interaction name
|
|
1211
|
-
'activity-instance-id',// activity instance ID
|
|
1212
1210
|
{
|
|
1213
1211
|
user: { id: 'user123' },
|
|
1214
1212
|
payload: { /* ... */ }
|
|
1215
|
-
}
|
|
1213
|
+
},
|
|
1214
|
+
'OrderProcess', // activity name (optional)
|
|
1215
|
+
'activity-instance-id' // activity instance ID (optional)
|
|
1216
1216
|
);
|
|
1217
1217
|
```
|
|
1218
1218
|
|
|
1219
1219
|
## Error Handling
|
|
1220
1220
|
|
|
1221
|
-
> **Important**: The interaqt framework automatically catches and handles all errors, never throwing uncaught exceptions. All errors are returned through the `error` field in the return value of `callInteraction
|
|
1221
|
+
> **Important**: The interaqt framework automatically catches and handles all errors, never throwing uncaught exceptions. All errors are returned through the `error` field in the return value of `callInteraction`. Therefore, **DO NOT use try-catch to test error cases**, instead check the `error` field in the return value.
|
|
1222
1222
|
|
|
1223
1223
|
### Parameter Validation Errors
|
|
1224
1224
|
|
|
@@ -150,12 +150,12 @@ const result = await controller.callInteraction(interactionName: string, args: {
|
|
|
150
150
|
payload?: { [key: string]: any } // Optional payload
|
|
151
151
|
})
|
|
152
152
|
|
|
153
|
-
// Call activity interaction
|
|
154
|
-
const result = await controller.
|
|
155
|
-
activityName: string,
|
|
153
|
+
// Call activity interaction (using the same callInteraction method)
|
|
154
|
+
const result = await controller.callInteraction(
|
|
156
155
|
interactionName: string,
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
args: InteractionEventArgs,
|
|
157
|
+
activityName: string, // Optional: for activity interactions
|
|
158
|
+
activityId: string // Optional: for activity interactions
|
|
159
159
|
)
|
|
160
160
|
```
|
|
161
161
|
|
|
@@ -1200,8 +1200,16 @@ Initialize system.
|
|
|
1200
1200
|
await controller.setup(true) // Create database tables
|
|
1201
1201
|
```
|
|
1202
1202
|
|
|
1203
|
-
#### callInteraction(interactionName: string, args: InteractionEventArgs)
|
|
1204
|
-
Call interaction.
|
|
1203
|
+
#### callInteraction(interactionName: string, args: InteractionEventArgs, activityName?: string, activityId?: string)
|
|
1204
|
+
Call interaction or activity interaction.
|
|
1205
|
+
|
|
1206
|
+
**Parameters:**
|
|
1207
|
+
- `interactionName`: The name of the interaction to call
|
|
1208
|
+
- `args`: The interaction event arguments containing user and payload
|
|
1209
|
+
- `activityName` (optional): The name of the activity when calling an activity interaction
|
|
1210
|
+
- `activityId` (optional): The ID of the activity instance when calling an activity interaction
|
|
1211
|
+
|
|
1212
|
+
**Example - Regular Interaction:**
|
|
1205
1213
|
```typescript
|
|
1206
1214
|
const result = await controller.callInteraction('createPost', {
|
|
1207
1215
|
user: { id: 'user1' },
|
|
@@ -1209,17 +1217,17 @@ const result = await controller.callInteraction('createPost', {
|
|
|
1209
1217
|
})
|
|
1210
1218
|
```
|
|
1211
1219
|
|
|
1212
|
-
|
|
1213
|
-
Call interaction within activity.
|
|
1220
|
+
**Example - Activity Interaction:**
|
|
1214
1221
|
```typescript
|
|
1215
|
-
const result = await controller.
|
|
1216
|
-
'OrderProcess',
|
|
1222
|
+
const result = await controller.callInteraction(
|
|
1217
1223
|
'confirmOrder',
|
|
1218
|
-
'
|
|
1219
|
-
|
|
1224
|
+
{ user: { id: 'user1' }, payload: { orderData: {...} } },
|
|
1225
|
+
'OrderProcess',
|
|
1226
|
+
'activity-instance-1'
|
|
1220
1227
|
)
|
|
1221
1228
|
```
|
|
1222
1229
|
|
|
1230
|
+
|
|
1223
1231
|
### System
|
|
1224
1232
|
|
|
1225
1233
|
System abstract interface that defines basic services like storage and logging.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
在需求分析的过程中,我们已经在 `.claude/agents/requirements-analysis-handle.md` 中提出了一种以最终"读需求"为起点,反向衍生出 创建/修改/删除 需求的方法。
|
|
2
|
+
在实际的探索中发现:用户可能会在输入阶段就按照自己的真实需要描述了一部分流程了,这个流程里面包含了
|
|
3
|
+
|
|
4
|
+
- 进行增删改查交互的步骤,通常是有依赖顺序的
|
|
5
|
+
- 进行交互的角色
|
|
6
|
+
- 交互对数据产生的具体增删改变化
|
|
7
|
+
例子:在 `requirements/requirements.md` 中,用户直接在描述中叙述如何创建版本 rollback 时数据应该如何变化。这里面就已经包含了:"创建版本-回退版本"的具体流程。
|
|
8
|
+
|
|
9
|
+
这个流程本身也是用户的一种需求,我们需要严格遵照他的指示实现。
|
|
10
|
+
现在,你来将 `.claude/agents/requirements-analysis-handle.md` 完全重写。要求:
|
|
11
|
+
1. 先将 `.claude/agents/requirements-analysis-handle.md` 关于目标补充、数据分析、交互动作定义的步骤、设计的数据结构完全提取出来,这些部分已经很稳定,可以留作复用。
|
|
12
|
+
|
|
13
|
+
用下面的这些步骤作为重写的分析步骤:
|
|
14
|
+
1. 对用户的输入进行分析,识别出其中的:
|
|
15
|
+
- 目标。通常是和具体软件功能无关,和现实中真实目标相关的描述。例如“管理图书”,“管理员工”,“和好友实时交流”等。
|
|
16
|
+
- 流程。例如 "发出好友申请-收到申请后同意/收到申请后拒绝"。
|
|
17
|
+
- 数据概念。(使用原文档里数据概念)。
|
|
18
|
+
2. 进行常见的目标补充(使用原文档里的方法)。
|
|
19
|
+
3. 进行完整的数据概念设计(复用原文档中的方法)。
|
|
20
|
+
4. 进行流程和交互动作设计。
|
|
21
|
+
3.1. 优先整合用户描述中的流程。并且看流程达到了哪些目标。
|
|
22
|
+
3.2. 为没有达到的目标设计流程。
|
|
23
|
+
3.2.1. 流程是一系列有顺序的交互的总和,其中可以包含可能的分支或者循环。交互的具体定义仍然采用原文档中的定义。
|
|
24
|
+
3.2.2. 流程的最后仍然应该是一个"读需求"作为结尾,来真正满足目标。但前面需要补充常见的创建等逻辑。
|
|
25
|
+
3.3. 注意,流程中的每一步应该都是一个交互动作,交互动作要使用原文档中 interactions-design.json 中的数据结构表示。要包含完整 `data.creates`/`data.updates`/`data.deletes`。从用户的输入中直接提取的出来的流程也要完善这些信息。
|
|
26
|
+
5. 设计完流程后。从数据的角度来补充用户可能需要的其他增删改查需求:
|
|
27
|
+
4.1. 为每一个修改和删除的交互考虑用户作为人类,是否需要经过查看/搜索再进行决策的需求。
|
|
28
|
+
4.2. 为每一个创建的交互动作考虑,数据在现实中是否允许修改/删除。如果允许就应该增加相应的需求。
|
|
29
|
+
6. 最终产出的 interactions-design.json 仍然使用原文档里的 interaction 数据结构,但以流程为组来组织。
|
|
30
|
+
|
|
31
|
+
注意,在每一个步骤中,都要给出清晰的数据结构定义,用 json 来写。
|
|
32
|
+
整体用简洁的英语完成文档重写。注意原本文档中的在关键步骤 update STATUS.json 仍然按照原文档的方式写。
|
|
33
|
+
|
|
34
|
+
|