MCPcopy Create free account
hub / github.com/astercloud/aster / artifactVersioningExample

Function artifactVersioningExample

examples/session-postgres/main.go:196–225  ·  view source on GitHub ↗

artifactVersioningExample 工件版本管理示例

(ctx context.Context, service *postgres.Service, sessionID string)

Source from the content-addressed store, hash-verified

194
195// artifactVersioningExample 工件版本管理示例
196func artifactVersioningExample(ctx context.Context, service *postgres.Service, sessionID string) {
197 // 模拟生成报告的多个版本
198 for version := 1; version <= 3; version++ {
199 event := &session.Event{
200 ID: "evt-" + generateID(),
201 Timestamp: time.Now(),
202 InvocationID: fmt.Sprintf("inv-artifact-%d", version),
203 AgentID: "agent-customer-support",
204 Branch: "root",
205 Author: "assistant",
206 Content: types.Message{
207 Role: types.RoleAssistant,
208 Content: fmt.Sprintf("生成报告版本 %d", version),
209 },
210 Actions: session.EventActions{
211 ArtifactDelta: map[string]int64{
212 "customer_report.pdf": int64(version),
213 },
214 },
215 }
216
217 if err := service.AppendEvent(ctx, sessionID, event); err != nil {
218 log.Fatalf("Failed to append artifact event: %v", err)
219 }
220
221 time.Sleep(100 * time.Millisecond)
222 }
223
224 fmt.Println("✅ Created 3 artifact versions")
225}
226
227// queryExample 查询和过滤示例
228func queryExample(ctx context.Context, service *postgres.Service, userID string) {

Callers 1

mainFunction · 0.85

Calls 2

generateIDFunction · 0.70
AppendEventMethod · 0.65

Tested by

no test coverage detected