vc

package
v1.0.86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VCDetail = common.Shortcut{
	Service:     "vc",
	Command:     "+detail",
	Description: "Get meeting details including note_id and minute_token by meeting IDs",
	Risk:        "read",
	Scopes:      []string{"vc:meeting.meetingevent:read", "vc:record:readonly"},
	AuthTypes:   []string{"user", "bot"},
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "meeting-ids", Desc: "meeting IDs, comma-separated for batch", Required: true},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		ids := common.SplitCSV(runtime.Str("meeting-ids"))
		const maxBatchSize = 50
		if len(ids) > maxBatchSize {
			return errs.NewValidationError(errs.SubtypeInvalidArgument, "--meeting-ids: too many IDs (%d), maximum is %d", len(ids), maxBatchSize).WithParam("--meeting-ids")
		}

		result, err := runtime.Factory.Credential.ResolveToken(ctx, credential.NewTokenSpec(runtime.As(), runtime.Config.AppID))
		if err == nil && result != nil && result.Scopes != "" {
			if missing := auth.MissingScopes(result.Scopes, scopesDetailMeetingIDs); len(missing) > 0 {
				return errs.NewPermissionError(errs.SubtypeMissingScope,
					"missing required scope(s): %s", strings.Join(missing, ", ")).
					WithMissingScopes(missing...).
					WithIdentity(string(runtime.As()))
			}
		}
		return nil
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		ids := runtime.Str("meeting-ids")
		return common.NewDryRunAPI().
			GET("/open-apis/vc/v1/meetings/{meeting_id}").
			GET("/open-apis/vc/v1/meetings/{meeting_id}/recording").
			Set("meeting_ids", common.SplitCSV(ids)).
			Set("steps", "meeting.get → note_id + recording API → minute_token")
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		errOut := runtime.IO().ErrOut
		meetingIDs := common.SplitCSV(runtime.Str("meeting-ids"))
		results := make([]*meetingDetailItem, 0, len(meetingIDs))

		const batchDelay = 100 * time.Millisecond
		fmt.Fprintf(errOut, "%s querying %d meeting_id(s)\n", detailLogPrefix, len(meetingIDs))
		for i, id := range meetingIDs {
			if err := ctx.Err(); err != nil {
				return err
			}
			if i > 0 {
				time.Sleep(batchDelay)
			}
			fmt.Fprintf(errOut, "%s querying meeting_id=%s ...\n", detailLogPrefix, sanitizeLogValue(id))
			results = append(results, fetchMeetingDetail(ctx, runtime, id))
		}

		successCount := 0
		for _, r := range results {
			if r.Error == "" {
				successCount++
			}
		}
		fmt.Fprintf(errOut, "%s done: %d total, %d succeeded, %d failed\n", detailLogPrefix, len(results), successCount, len(results)-successCount)

		if successCount == 0 && len(results) > 0 {
			return runtime.OutPartialFailure(map[string]any{"meetings": results}, &output.Meta{Count: len(results)})
		}

		outData := map[string]any{"meetings": results}
		runtime.OutFormat(outData, &output.Meta{Count: len(results)}, func(w io.Writer) {
			if len(results) == 0 {
				fmt.Fprintln(w, "No meetings.")
				return
			}
			var rows []map[string]interface{}
			for _, r := range results {
				row := map[string]interface{}{"meeting_id": r.MeetingID}
				if r.Error != "" {
					row["status"] = "FAIL"
					row["error"] = r.Error
				} else {
					row["status"] = "OK"
				}
				if r.NoteID != "" {
					row["note_id"] = r.NoteID
				}
				if r.MinuteToken != "" {
					row["minute_token"] = r.MinuteToken
				}
				row["topic"] = r.Topic
				if r.Hint != "" {
					row["hint"] = r.Hint
				}
				rows = append(rows, row)
			}
			output.PrintTable(w, rows)
			fmt.Fprintf(w, "\n%d meeting(s), %d succeeded, %d failed\n", len(results), successCount, len(results)-successCount)
		})
		return nil
	},
}

VCDetail gets meeting details including note_id and minute_token.

View Source
var VCMeetingEvents = common.Shortcut{
	Service:     "vc",
	Command:     "+meeting-events",
	Description: "List meeting events by meeting ID",
	Risk:        "read",

	UserScopes:           []string{meetingQueryUserScope},
	ConditionalBotScopes: []string{meetingQueryBotScope},
	AuthTypes:            []string{"user", "bot"},
	HasFormat:            true,
	Flags: []common.Flag{
		{Name: "meeting-id", Required: true, Desc: "meeting ID to query"},
		{Name: "start", Desc: "time lower bound (ISO 8601, YYYY-MM-DD, or Unix seconds)"},
		{Name: "end", Desc: "time upper bound (ISO 8601, YYYY-MM-DD, or Unix seconds)"},
		{Name: "page-token", Desc: "page token for the next page"},
		{Name: "page-size", Default: "20", Desc: "page size, 20-100 (default 20)"},
		{Name: "page-all", Type: "bool", Desc: "automatically paginate through all available pages"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		if err := validateMeetingEventsMeetingID(runtime.Str("meeting-id")); err != nil {
			return err
		}
		if _, err := meetingEventsPageSize(runtime); err != nil {
			return err
		}
		if _, _, err := parseMeetingEventsTimeRange(runtime); err != nil {
			return err
		}
		return nil
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		startTime, endTime, err := parseMeetingEventsTimeRange(runtime)
		if err != nil {
			return common.NewDryRunAPI().Set("error", err.Error())
		}
		params, err := buildMeetingEventsParams(runtime, startTime, endTime)
		if err != nil {
			return common.NewDryRunAPI().Set("error", err.Error())
		}
		dryRun := common.NewDryRunAPI()
		if runtime.Bool("page-all") {
			dryRun = dryRun.Desc("Auto-paginates through all available pages")
		}
		dryRun = dryRun.GET(vcMeetingEventsAPIPath)
		if flat := flattenQueryParams(params); len(flat) > 0 {
			dryRun.Params(flat)
		}
		return dryRun
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		startTime, endTime, err := parseMeetingEventsTimeRange(runtime)
		if err != nil {
			return err
		}
		data, events, hasMore, pageToken, err := fetchMeetingEvents(ctx, runtime, startTime, endTime)
		if err != nil {
			return normalizeMeetingQueryPermissionError(runtime, err)
		}
		events = compactMeetingEvents(events)
		identity, identityWarning := meetingEventsCurrentIdentity(runtime)
		outData := buildMeetingEventsOutput(data, events, identity, identityWarning)
		metadata := map[string]interface{}{
			"row_type":   "metadata",
			"meeting":    outData.Meeting,
			"identity":   outData.Identity,
			"has_more":   outData.HasMore,
			"page_token": outData.PageToken,
		}
		if len(outData.Warnings) > 0 {
			metadata["warnings"] = outData.Warnings
		}
		ndjsonData := meetingEventsEventRows(outData.Events, metadata)

		timeline := buildMeetingEventTimeline(events)
		if runtime.Format == "ndjson" {
			runtime.OutFormat(ndjsonData, &output.Meta{Count: len(events)}, func(w io.Writer) {})
		} else {
			runtime.OutFormat(outData, &output.Meta{Count: len(events)}, func(w io.Writer) {
				renderMeetingEventsCompactPretty(w, outData, timeline)
			})
		}
		if runtime.Format == "pretty" && pageToken != "" {
			fmt.Fprintf(runtime.IO().Out, "\npage_token: %s\n", pageToken)
			if hasMore {
				fmt.Fprintln(runtime.IO().Out, "more available")
			}
		}
		return nil
	},
}

VCMeetingEvents lists meeting events for a meeting.

View Source
var VCMeetingJoin = common.Shortcut{
	Service:     "vc",
	Command:     "+meeting-join",
	Description: "Join a meeting by meeting number (bot join)",
	Risk:        "write",
	Scopes:      []string{"vc:meeting.bot.join:write"},
	AuthTypes:   []string{"user", "bot"},
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "meeting-number", Required: true, Desc: "meeting number to join"},
		{Name: "password", Desc: "meeting password (if required)"},
		{Name: "call-id", Desc: "correlation id forwarded from invite event"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		mn := strings.TrimSpace(runtime.Str("meeting-number"))
		if !validMeetingNumber(mn) {
			return errs.NewValidationError(errs.SubtypeInvalidArgument, "--meeting-number must be exactly 9 digits, got %q", mn).WithParam("--meeting-number")
		}
		return nil
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		body := buildMeetingJoinBody(runtime)
		return common.NewDryRunAPI().
			POST("/open-apis/vc/v1/bots/join").
			Body(body)
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		body := buildMeetingJoinBody(runtime)
		data, err := runtime.CallAPITyped("POST", "/open-apis/vc/v1/bots/join", nil, body)
		if err != nil {
			return err
		}
		if data == nil {
			data = map[string]interface{}{}
		}
		runtime.OutFormat(data, nil, func(w io.Writer) {
			meeting, _ := data["meeting"].(map[string]interface{})
			if meeting == nil {
				fmt.Fprintln(w, "Joined meeting (no meeting info returned).")
				return
			}
			fmt.Fprintf(w, "Joined meeting successfully.\n")
			if id := common.GetString(meeting, "id"); id != "" {
				fmt.Fprintf(w, "  Meeting ID:  %s\n", id)
			}
			if no := common.GetString(meeting, "meeting_no"); no != "" {
				fmt.Fprintf(w, "  Meeting No:  %s\n", no)
			}
			if topic := common.GetString(meeting, "topic"); topic != "" {
				fmt.Fprintf(w, "  Topic:       %s\n", topic)
			}
			if startTime := common.GetString(meeting, "start_time"); startTime != "" {
				fmt.Fprintf(w, "  Start Time:  %s\n", startTime)
			}
		})
		return nil
	},
}

VCMeetingJoin joins a meeting by meeting number via /vc/v1/bots/join.

View Source
var VCMeetingLeave = common.Shortcut{
	Service:     "vc",
	Command:     "+meeting-leave",
	Description: "Leave a meeting by meeting ID",
	Risk:        "write",
	Scopes:      []string{"vc:meeting.bot.join:write"},
	AuthTypes:   []string{"user", "bot"},
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "meeting-id", Required: true, Desc: "meeting ID to leave"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		if strings.TrimSpace(runtime.Str("meeting-id")) == "" {
			return errs.NewValidationError(errs.SubtypeInvalidArgument, "--meeting-id is required").WithParam("--meeting-id")
		}
		return nil
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		return common.NewDryRunAPI().
			POST("/open-apis/vc/v1/bots/leave").
			Body(map[string]interface{}{
				"meeting_id": strings.TrimSpace(runtime.Str("meeting-id")),
			})
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		meetingID := strings.TrimSpace(runtime.Str("meeting-id"))
		body := map[string]interface{}{
			"meeting_id": meetingID,
		}
		data, err := runtime.CallAPITyped("POST", "/open-apis/vc/v1/bots/leave", nil, body)
		if err != nil {
			return err
		}
		if data == nil {
			data = map[string]interface{}{}
		}
		runtime.OutFormat(data, nil, func(w io.Writer) {
			fmt.Fprintf(w, "Left meeting %s successfully.\n", meetingID)
		})
		return nil
	},
}

VCMeetingLeave leaves a meeting via /vc/v1/bots/leave.

View Source
var VCMeetingListActive = common.Shortcut{
	Service:     "vc",
	Command:     "+meeting-list-active",
	Description: "List active meetings for the current identity or target user",
	Risk:        "read",

	UserScopes:           []string{meetingQueryUserScope},
	ConditionalBotScopes: []string{meetingQueryBotScope},
	AuthTypes:            []string{"user", "bot"},
	HasFormat:            true,
	Flags: []common.Flag{
		{Name: "user-id", Desc: "target user ID when using bot identity"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		return validateMeetingListActiveUserID(runtime)
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		params, err := buildMeetingListActiveParams(runtime)
		if err != nil {
			return common.NewDryRunAPI().Set("error", err.Error())
		}
		dryRun := common.NewDryRunAPI().GET(vcMeetingListActiveAPIPath)
		if len(params) > 0 {
			dryRun.Params(params)
		}
		return dryRun
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		params, err := buildMeetingListActiveParams(runtime)
		if err != nil {
			return err
		}
		data, err := runtime.CallAPITyped(http.MethodGet, vcMeetingListActiveAPIPath, params, nil)
		if err != nil {
			return normalizeMeetingQueryPermissionError(runtime, err)
		}
		if data == nil {
			data = map[string]interface{}{}
		}
		meetings := common.GetSlice(data, "meetings")
		runtime.OutFormat(data, &output.Meta{Count: len(meetings)}, func(w io.Writer) {
			if len(meetings) == 0 {
				fmt.Fprintln(w, "No active meetings.")
				return
			}
			displayedMeetings := 0
			for _, raw := range meetings {
				meeting, _ := raw.(map[string]interface{})
				if meeting == nil {
					continue
				}
				if displayedMeetings > 0 {
					fmt.Fprintln(w)
				}
				displayedMeetings++
				title := common.GetString(meeting, "meeting_title")
				if title == "" {
					title = "Untitled meeting"
				}
				fmt.Fprintf(w, "%s\n", title)
				if id := common.GetString(meeting, "meeting_id"); id != "" {
					fmt.Fprintf(w, "  Meeting ID:  %s\n", id)
				}
				if no := common.GetString(meeting, "meeting_no"); no != "" {
					fmt.Fprintf(w, "  Meeting No:  %s\n", no)
				}
			}
			if displayedMeetings > 1 {
				fmt.Fprintln(w)
				fmt.Fprintln(w, "Multiple active meetings found. Ask the user to choose one meeting_id before calling +meeting-events.")
			}
		})
		return nil
	},
}

VCMeetingListActive lists meetings the current or target user is actively in.

View Source
var VCMeetingMessageSend = common.Shortcut{
	Service:     "vc",
	Command:     "+meeting-message-send",
	Description: "Send an in-meeting text message or reaction emoji",
	Risk:        "write",
	Scopes:      []string{"vc:meeting.message:write"},
	AuthTypes:   []string{"user", "bot"},
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "meeting-id", Required: true, Desc: "meeting ID to send into"},
		{Name: "msg-type", Desc: "message type: text or reaction"},
		{Name: "text", Desc: "text content when --msg-type text"},
		{Name: "emoji-type", Desc: "emoji key when --msg-type reaction, for example LOVE, THUMBSUP, VC_NoSound"},
		{Name: "uuid", Desc: "optional idempotency key"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		if err := validateMeetingEventsMeetingID(runtime.Str("meeting-id")); err != nil {
			return err
		}
		_, err := validateMeetingMessagePayload(runtime)
		return err
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		body, err := buildMeetingMessageSendBody(runtime)
		if err != nil {
			return common.NewDryRunAPI().Set("error", err.Error())
		}
		return common.NewDryRunAPI().
			POST(buildMeetingMessageSendPath()).
			Body(body)
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		body, err := buildMeetingMessageSendBody(runtime)
		if err != nil {
			return err
		}
		data, err := runtime.CallAPITyped(http.MethodPost, buildMeetingMessageSendPath(), nil, body)
		if err != nil {
			return err
		}
		if data == nil {
			data = map[string]interface{}{}
		}
		runtime.OutFormat(data, nil, func(w io.Writer) {
			fmt.Fprintln(w, "Meeting message sent.")
			if msgType := common.GetString(data, "msg_type"); msgType != "" {
				fmt.Fprintf(w, "  Type:  %s\n", msgType)
			} else if msgType, _ := body["msg_type"].(string); msgType != "" {
				fmt.Fprintf(w, "  Type:  %s\n", msgType)
			}
			if uuid := common.GetString(data, "uuid"); uuid != "" {
				fmt.Fprintf(w, "  UUID:  %s\n", uuid)
			}
		})
		return nil
	},
}

VCMeetingMessageSend sends an in-meeting text message or reaction emoji.

View Source
var VCNotes = common.Shortcut{
	Service:     "vc",
	Command:     "+notes",
	Description: "Query meeting notes (via meeting-ids, minute-tokens, or calendar-event-ids)",
	Risk:        "read",
	Scopes:      []string{"vc:note:read"},
	AuthTypes:   []string{"user", "bot"},
	Hidden:      true,
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "meeting-ids", Desc: "meeting IDs, comma-separated for batch"},
		{Name: "minute-tokens", Desc: "minute tokens, comma-separated for batch"},
		{Name: "calendar-event-ids", Desc: "calendar event instance IDs, comma-separated for batch"},
		{Name: "output-dir", Desc: "output directory for artifact files (default: ./minutes/{minute_token}/)"},
		{Name: "overwrite", Type: "bool", Desc: "overwrite existing artifact files"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		if err := common.ExactlyOneTyped(runtime, "meeting-ids", "minute-tokens", "calendar-event-ids"); err != nil {
			return err
		}
		// batch input size limit
		const maxBatchSize = 50
		for _, flag := range []string{"meeting-ids", "minute-tokens", "calendar-event-ids"} {
			if v := runtime.Str(flag); v != "" {
				if ids := common.SplitCSV(v); len(ids) > maxBatchSize {
					return errs.NewValidationError(errs.SubtypeInvalidArgument, "--%s: too many IDs (%d), maximum is %d", flag, len(ids), maxBatchSize).WithParam("--" + flag)
				}
			}
		}
		if outDir := runtime.Str("output-dir"); outDir != "" {
			if err := common.ValidateSafePathTyped(runtime.FileIO(), outDir); err != nil {
				return err
			}
		}

		if v := runtime.Str("minute-tokens"); v != "" {
			for _, token := range common.SplitCSV(v) {
				if !validMinuteToken.MatchString(token) {
					return errs.NewValidationError(errs.SubtypeInvalidArgument, "invalid minute token %q: must contain only lowercase alphanumeric characters", token).WithParam("--minute-tokens")
				}
			}
		}
		// dynamic scope check based on which flag is provided
		var required []string
		switch {
		case runtime.Str("meeting-ids") != "":
			required = scopesMeetingIDs
		case runtime.Str("minute-tokens") != "":
			required = scopesMinuteTokens
		case runtime.Str("calendar-event-ids") != "":
			required = scopesCalendarEventIDs
		default:

		}
		result, err := runtime.Factory.Credential.ResolveToken(ctx, credential.NewTokenSpec(runtime.As(), runtime.Config.AppID))
		if err == nil && result != nil && result.Scopes != "" {
			if missing := auth.MissingScopes(result.Scopes, required); len(missing) > 0 {
				return errs.NewPermissionError(errs.SubtypeMissingScope,
					"missing required scope(s): %s", strings.Join(missing, ", ")).
					WithMissingScopes(missing...).
					WithIdentity(string(runtime.As()))
			}
		}
		return nil
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		if ids := runtime.Str("meeting-ids"); ids != "" {
			return common.NewDryRunAPI().
				GET("/open-apis/vc/v1/meetings/{meeting_id}").
				GET("/open-apis/vc/v1/notes/{note_id}").
				GET("/open-apis/vc/v1/meetings/{meeting_id}/recording").
				Set("meeting_ids", common.SplitCSV(ids)).
				Set("steps", "meeting.get → note_id → note detail API + recording API → minute_token")
		}
		if tokens := runtime.Str("minute-tokens"); tokens != "" {
			return common.NewDryRunAPI().
				GET("/open-apis/minutes/v1/minutes/{minute_token}").
				GET("/open-apis/vc/v1/notes/{note_id}").
				GET("/open-apis/minutes/v1/minutes/{minute_token}/artifacts").
				Set("minute_tokens", common.SplitCSV(tokens)).
				Set("steps", "minutes API → note detail + AI artifacts (incl. transcript)")
		}
		ids := runtime.Str("calendar-event-ids")
		return common.NewDryRunAPI().
			POST("/open-apis/calendar/v4/calendars/primary").
			POST("/open-apis/calendar/v4/calendars/{calendar_id}/events/mget_instance_relation_info").
			GET("/open-apis/vc/v1/meetings/{meeting_id}").
			GET("/open-apis/vc/v1/notes/{note_id}").
			GET("/open-apis/vc/v1/meetings/{meeting_id}/recording").
			Set("calendar_event_ids", common.SplitCSV(ids)).
			Set("steps", "primary calendar → mget_instance_relation_info → meeting_id → meeting.get → note detail API + recording API → minute_token")
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		errOut := runtime.IO().ErrOut
		var results []any

		const batchDelay = 100 * time.Millisecond

		if ids := runtime.Str("meeting-ids"); ids != "" {
			meetingIDs := common.SplitCSV(ids)
			fmt.Fprintf(errOut, "%s querying %d meeting_id(s)\n", logPrefix, len(meetingIDs))
			for i, id := range meetingIDs {
				if err := ctx.Err(); err != nil {
					return err
				}
				if i > 0 {
					time.Sleep(batchDelay)
				}
				fmt.Fprintf(errOut, "%s querying meeting_id=%s ...\n", logPrefix, sanitizeLogValue(id))
				results = append(results, fetchNoteByMeetingID(ctx, runtime, id))
			}
		} else if tokens := runtime.Str("minute-tokens"); tokens != "" {
			minuteTokens := common.SplitCSV(tokens)
			fmt.Fprintf(errOut, "%s querying %d minute_token(s)\n", logPrefix, len(minuteTokens))
			for i, token := range minuteTokens {
				if err := ctx.Err(); err != nil {
					return err
				}
				if i > 0 {
					time.Sleep(batchDelay)
				}
				fmt.Fprintf(errOut, "%s querying minute_token=%s ...\n", logPrefix, sanitizeLogValue(token))
				results = append(results, fetchNoteByMinuteToken(ctx, runtime, token))
			}
		} else {
			instanceIDs := common.SplitCSV(runtime.Str("calendar-event-ids"))
			fmt.Fprintf(errOut, "%s querying %d calendar_event_id(s)\n", logPrefix, len(instanceIDs))
			calendarID, err := getPrimaryCalendarID(runtime)
			if err != nil {
				return err
			}
			fmt.Fprintf(errOut, "%s primary calendar: %s\n", logPrefix, calendarID)
			for i, id := range instanceIDs {
				if err := ctx.Err(); err != nil {
					return err
				}
				if i > 0 {
					time.Sleep(batchDelay)
				}
				fmt.Fprintf(errOut, "%s querying calendar_event_id=%s ...\n", logPrefix, sanitizeLogValue(id))
				results = append(results, fetchNoteByCalendarEventID(ctx, runtime, id, calendarID))
			}
		}

		successCount := 0
		for _, r := range results {
			m, _ := r.(map[string]any)
			if hasNotesPayload(m) {
				successCount++
			}
		}
		fmt.Fprintf(errOut, "%s done: %d total, %d succeeded, %d failed\n", logPrefix, len(results), successCount, len(results)-successCount)

		if successCount == 0 && len(results) > 0 {
			return runtime.OutPartialFailure(map[string]any{"notes": results}, &output.Meta{Count: len(results)})
		}

		outData := map[string]any{"notes": results}
		runtime.OutFormat(outData, &output.Meta{Count: len(results)}, func(w io.Writer) {
			var rows []map[string]interface{}
			for _, r := range results {
				m, _ := r.(map[string]any)
				id, _ := m["meeting_id"].(string)
				if id == "" {
					id, _ = m["minute_token"].(string)
				}
				if id == "" {
					id, _ = m["calendar_event_id"].(string)
				}
				row := map[string]interface{}{"id": id}
				if v, _ := m["note_id"].(string); v != "" {
					row["note_id"] = v
				}
				if v, _ := m["note_display_type"].(string); v != "" {
					row["note_display_type"] = v
				}
				if errMsg, _ := m["error"].(string); errMsg != "" {
					row["status"] = "FAIL"
					row["error"] = errMsg
				} else {
					row["status"] = "OK"
					if v, _ := m["note_doc_token"].(string); v != "" {
						row["note_doc"] = v
					}
					if v, _ := m["verbatim_doc_token"].(string); v != "" {
						row["verbatim_doc"] = v
					}
					if v, _ := m["shared_doc_tokens"].([]string); len(v) > 0 {
						row["shared_docs"] = strings.Join(v, ", ")
					}
					if v := asStringSlice(m["meeting_notes"]); len(v) > 0 {
						row["meeting_notes"] = strings.Join(v, ", ")
					}
					if v, _ := m["source"].(string); v != "" {
						row["source"] = v
					}
					if v, _ := m["create_time"].(string); v != "" {
						row["create_time"] = v
					}
					if arts, _ := m["artifacts"].(map[string]any); arts != nil {
						if v, _ := arts["transcript_file"].(string); v != "" {
							row["transcript"] = v
						}
					}
				}
				rows = append(rows, row)
			}
			output.PrintTable(w, rows)
			fmt.Fprintf(w, "\n%d note(s), %d succeeded, %d failed\n", len(results), successCount, len(results)-successCount)
		})
		return nil
	},
}

VCNotes queries meeting notes via meeting-ids, minute-tokens, or calendar-event-ids.

View Source
var VCRecording = common.Shortcut{
	Service:     "vc",
	Command:     "+recording",
	Description: "Query minute_token from meeting-ids or calendar-event-ids",
	Risk:        "read",
	Scopes:      []string{"vc:record:readonly"},
	AuthTypes:   []string{"user", "bot"},
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "meeting-ids", Desc: "meeting IDs, comma-separated for batch"},
		{Name: "calendar-event-ids", Desc: "calendar event instance IDs, comma-separated for batch"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		if err := common.ExactlyOneTyped(runtime, "meeting-ids", "calendar-event-ids"); err != nil {
			return err
		}
		const maxBatchSize = 50
		for _, flag := range []string{"meeting-ids", "calendar-event-ids"} {
			if v := runtime.Str(flag); v != "" {
				if ids := common.SplitCSV(v); len(ids) > maxBatchSize {
					return errs.NewValidationError(errs.SubtypeInvalidArgument, "--%s: too many IDs (%d), maximum is %d", flag, len(ids), maxBatchSize).WithParam("--" + flag)
				}
			}
		}
		var required []string
		switch {
		case runtime.Str("meeting-ids") != "":
			required = scopesRecordingMeetingIDs
		case runtime.Str("calendar-event-ids") != "":
			required = scopesRecordingCalendarEventIDs
		}
		result, err := runtime.Factory.Credential.ResolveToken(ctx, credential.NewTokenSpec(runtime.As(), runtime.Config.AppID))
		if err == nil && result != nil && result.Scopes != "" {
			if missing := auth.MissingScopes(result.Scopes, required); len(missing) > 0 {
				return errs.NewPermissionError(errs.SubtypeMissingScope,
					"missing required scope(s): %s", strings.Join(missing, ", ")).
					WithMissingScopes(missing...).
					WithIdentity(string(runtime.As()))
			}
		}
		return nil
	},
	DryRun: func(_ context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		if ids := runtime.Str("meeting-ids"); ids != "" {
			return common.NewDryRunAPI().
				GET("/open-apis/vc/v1/meetings/{meeting_id}/recording").
				Set("meeting_ids", common.SplitCSV(ids)).
				Set("steps", "meeting recording API → extract minute_token from URL")
		}
		ids := runtime.Str("calendar-event-ids")
		return common.NewDryRunAPI().
			POST("/open-apis/calendar/v4/calendars/primary").
			POST("/open-apis/calendar/v4/calendars/{calendar_id}/events/mget_instance_relation_info").
			GET("/open-apis/vc/v1/meetings/{meeting_id}/recording").
			Set("calendar_event_ids", common.SplitCSV(ids)).
			Set("steps", "primary calendar → mget_instance_relation_info → meeting_id → recording API → extract minute_token")
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		errOut := runtime.IO().ErrOut
		var results []any

		const batchDelay = 100 * time.Millisecond

		if ids := runtime.Str("meeting-ids"); ids != "" {
			meetingIDs := common.SplitCSV(ids)
			fmt.Fprintf(errOut, "%s querying %d meeting_id(s)\n", recordingLogPrefix, len(meetingIDs))
			for i, id := range meetingIDs {
				if err := ctx.Err(); err != nil {
					return err
				}
				if i > 0 {
					time.Sleep(batchDelay)
				}
				fmt.Fprintf(errOut, "%s querying meeting_id=%s ...\n", recordingLogPrefix, sanitizeLogValue(id))
				results = append(results, fetchRecordingByMeetingID(ctx, runtime, id))
			}
		} else {
			instanceIDs := common.SplitCSV(runtime.Str("calendar-event-ids"))
			fmt.Fprintf(errOut, "%s querying %d calendar_event_id(s)\n", recordingLogPrefix, len(instanceIDs))
			calendarID, err := getPrimaryCalendarID(runtime)
			if err != nil {
				return err
			}
			fmt.Fprintf(errOut, "%s primary calendar: %s\n", recordingLogPrefix, calendarID)
			for i, instanceID := range instanceIDs {
				if err := ctx.Err(); err != nil {
					return err
				}
				if i > 0 {
					time.Sleep(batchDelay)
				}
				fmt.Fprintf(errOut, "%s resolving calendar_event_id=%s ...\n", recordingLogPrefix, sanitizeLogValue(instanceID))
				relInfo, resolveErr := resolveMeetingIDsFromCalendarEvent(runtime, instanceID, calendarID, false)
				if resolveErr != nil {
					results = append(results, calendarEventResolutionFailure(runtime, instanceID, resolveErr))
					continue
				}
				found := false
				for _, meetingID := range relInfo.MeetingIDs {
					fmt.Fprintf(errOut, "%s event %s → meeting_id=%s\n", recordingLogPrefix, sanitizeLogValue(instanceID), sanitizeLogValue(meetingID))
					result := fetchRecordingByMeetingID(ctx, runtime, meetingID)
					if result["error"] == nil {
						result["calendar_event_id"] = instanceID
						results = append(results, result)
						found = true
						break
					}
					fmt.Fprintf(errOut, "%s meeting_id=%s: %s, trying next\n", recordingLogPrefix, sanitizeLogValue(meetingID), result["error"])
				}
				if !found {
					results = append(results, map[string]any{"calendar_event_id": instanceID, "error": "no recording found in any associated meeting"})
				}
			}
		}

		successCount := 0
		for _, r := range results {
			m, _ := r.(map[string]any)
			if m["error"] == nil {
				successCount++
			}
		}
		fmt.Fprintf(errOut, "%s done: %d total, %d succeeded, %d failed\n", recordingLogPrefix, len(results), successCount, len(results)-successCount)

		if successCount == 0 && len(results) > 0 {
			return runtime.OutPartialFailure(map[string]any{"recordings": results}, &output.Meta{Count: len(results)})
		}

		outData := map[string]any{"recordings": results}
		runtime.OutFormat(outData, &output.Meta{Count: len(results)}, func(w io.Writer) {
			var rows []map[string]interface{}
			for _, r := range results {
				m, _ := r.(map[string]any)
				meetingID, _ := m["meeting_id"].(string)
				row := map[string]interface{}{}
				if meetingID != "" {
					row["meeting_id"] = meetingID
				}
				if calEventID, _ := m["calendar_event_id"].(string); calEventID != "" {
					row["calendar_event_id"] = calEventID
				}
				if errMsg, _ := m["error"].(string); errMsg != "" {
					row["status"] = "FAIL"
					row["error"] = errMsg
				} else {
					row["status"] = "OK"
					if v, _ := m["minute_token"].(string); v != "" {
						row["minute_token"] = v
					}
					if v, _ := m["duration"].(string); v != "" {
						row["duration"] = v
					}
				}
				rows = append(rows, row)
			}
			output.PrintTable(w, rows)
			fmt.Fprintf(w, "\n%d recording(s), %d succeeded, %d failed\n", len(results), successCount, len(results)-successCount)
		})
		return nil
	},
}

VCRecording gets meeting recording info and extracts minute_token.

View Source
var VCSearch = common.Shortcut{
	Service:     "vc",
	Command:     "+search",
	Description: "Search meeting records by keyword, time range, participant, organizer, or meeting room (requires at least one filter)",
	Risk:        "read",
	Scopes:      []string{"vc:meeting.search:read"},
	AuthTypes:   []string{"user"},
	HasFormat:   true,
	Flags: []common.Flag{
		{Name: "query", Desc: "search keyword"},
		{Name: "start", Desc: "start time (ISO 8601 or YYYY-MM-DD, e.g. 2026-03-24T00:00+08:00)"},
		{Name: "end", Desc: "end time (ISO 8601 or YYYY-MM-DD, e.g. 2026-03-25)"},
		{Name: "organizer-ids", Desc: "organizer open_id list, comma-separated"},
		{Name: "participant-ids", Desc: "participant open_id list, comma-separated"},
		{Name: "room-ids", Desc: "room_id list, comma-separated"},
		{Name: "page-token", Desc: "page token for next page"},
		{Name: "page-size", Default: "15", Desc: "page size, 1-30 (default 15)"},
	},
	Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
		if _, _, err := parseTimeRange(runtime); err != nil {
			return err
		}
		if q := strings.TrimSpace(runtime.Str("query")); q != "" && utf8.RuneCountInString(q) > maxVCSearchQueryLen {
			return errs.NewValidationError(errs.SubtypeInvalidArgument, "--query: length must be between 1 and 50 characters").WithParam("--query")
		}
		if _, err := common.ValidatePageSizeTyped(runtime, "page-size", defaultVCSearchPageSize, 1, maxVCSearchPageSize); err != nil {
			return err
		}
		for _, flag := range []string{"query", "start", "end", "organizer-ids", "participant-ids", "room-ids"} {
			if strings.TrimSpace(runtime.Str(flag)) != "" {
				return nil
			}
		}
		return errs.NewValidationError(errs.SubtypeInvalidArgument, "specify at least one of --query, --start, --end, --organizer-ids, --participant-ids, or --room-ids")
	},
	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
		startTime, endTime, err := parseTimeRange(runtime)
		if err != nil {
			return common.NewDryRunAPI().Set("error", err.Error())
		}
		params := buildSearchParams(runtime)
		dryRun := common.NewDryRunAPI().
			POST("/open-apis/vc/v1/meetings/search")
		if len(params) > 0 {
			dryRun.Params(params)
		}
		return dryRun.Body(buildSearchBody(runtime, startTime, endTime))
	},
	Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
		startTime, endTime, err := parseTimeRange(runtime)
		if err != nil {
			return err
		}
		data, err := runtime.CallAPITyped("POST", "/open-apis/vc/v1/meetings/search", buildSearchParams(runtime), buildSearchBody(runtime, startTime, endTime))
		if err != nil {
			return err
		}
		if data == nil {
			data = map[string]interface{}{}
		}
		items := common.GetSlice(data, "items")

		for _, raw := range items {
			if m, ok := raw.(map[string]interface{}); ok {
				if meta, ok := m["meta_data"].(map[string]interface{}); ok {
					delete(meta, "avatar")
				}
			}
		}
		outData := map[string]interface{}{
			"items":      items,
			"has_more":   data["has_more"],
			"page_token": data["page_token"],
		}
		if notice, _ := data["notice"].(string); notice != "" {
			outData["notice"] = notice
		}
		hasMore, _ := data["has_more"].(bool)
		runtime.OutFormat(outData, &output.Meta{Count: len(items)}, func(w io.Writer) {
			if len(items) == 0 {
				fmt.Fprintln(w, "No meetings.")
				return
			}
			var rows []map[string]interface{}
			common.EachMap(items, func(item map[string]interface{}) {
				rows = append(rows, map[string]interface{}{
					"id":           fmt.Sprintf("%v", item["id"]),
					"display_info": common.TruncateStr(meetingSearchDisplayInfo(item), 40),
					"meta_data":    common.TruncateStr(meetingSearchDescription(item), 80),
				})
			})
			output.PrintTable(w, rows)
		})

		if hasMore && runtime.Format != "json" && runtime.Format != "" {
			pt, _ := data["page_token"].(string)
			fmt.Fprintf(runtime.IO().Out, "\n(more available, page_token: %s)\n", pt)
		}
		return nil
	},
}

VCSearch searches historical meeting records with filters.

Functions

func Shortcuts

func Shortcuts() []common.Shortcut

Shortcuts returns all vc shortcuts.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL