Repository navigation
feat(runtime): type Linear agent session events #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,112 @@ export interface WorkforceProviderEvent extends WorkforceEventBase { | |
| }; | ||
| } | ||
|
|
||
| export type WorkforceEvent = WorkforceCronEvent | WorkforceProviderEvent; | ||
| export function unwrapResourceRecord<T = unknown>(payload: unknown): T | unknown { | ||
| const resource = isRecord(payload) && 'resource' in payload ? payload.resource : payload; | ||
| return isRecord(resource) && 'payload' in resource ? resource.payload : resource; | ||
| } | ||
|
|
||
| export interface LinearIssueReference { | ||
| id: string; | ||
| identifier?: string; | ||
| title?: string; | ||
| url?: string; | ||
| } | ||
|
|
||
| export interface LinearAgentSession { | ||
| id: string; | ||
| issue?: LinearIssueReference; | ||
| [key: string]: unknown; | ||
| } | ||
|
|
||
| export type LinearAgentActivityType = | ||
| | 'action' | ||
| | 'elicitation' | ||
| | 'error' | ||
| | 'response' | ||
| | 'thought'; | ||
|
|
||
| export interface LinearAgentActivity { | ||
| type?: LinearAgentActivityType | string; | ||
| body?: string; | ||
| action?: string; | ||
| parameter?: string; | ||
| result?: string; | ||
| } | ||
|
|
||
| export interface LinearAgentSessionPayload { | ||
| type: 'AgentSessionEvent'; | ||
| action: 'created' | 'prompted' | string; | ||
| agentSession: LinearAgentSession; | ||
| agentActivity?: LinearAgentActivity & { | ||
| id?: string; | ||
| agentSessionId?: string; | ||
| content?: LinearAgentActivity; | ||
| [key: string]: unknown; | ||
| }; | ||
| issue?: LinearIssueReference; | ||
| promptContext?: string; | ||
| notification?: { | ||
| issue?: LinearIssueReference; | ||
| comment?: { id?: string; body?: string; [key: string]: unknown }; | ||
| [key: string]: unknown; | ||
| }; | ||
| [key: string]: unknown; | ||
| } | ||
|
|
||
| export interface LinearAppUserNotificationPayload { | ||
| type: 'AppUserNotification'; | ||
| action: 'issueCommentMention' | string; | ||
| issue?: LinearIssueReference; | ||
| comment?: { id?: string; body?: string; [key: string]: unknown }; | ||
| notification?: { | ||
| issue?: LinearIssueReference; | ||
| comment?: { id?: string; body?: string; [key: string]: unknown }; | ||
| [key: string]: unknown; | ||
| }; | ||
| [key: string]: unknown; | ||
| } | ||
|
|
||
| export interface LinearWrappedPayload<TRecord> { | ||
| resource: { | ||
| payload: TRecord; | ||
| [key: string]: unknown; | ||
| }; | ||
| [key: string]: unknown; | ||
| } | ||
|
|
||
| export type LinearAgentSessionEventPayload = | ||
| LinearWrappedPayload<LinearAgentSessionPayload> & { | ||
| agentSession?: LinearAgentSession; | ||
| agentActivity?: LinearAgentSessionPayload['agentActivity']; | ||
| issue?: LinearIssueReference; | ||
| promptContext?: string; | ||
| }; | ||
|
|
||
| export type LinearAppUserNotificationEventPayload = | ||
| LinearWrappedPayload<LinearAppUserNotificationPayload> & { | ||
| issue?: LinearIssueReference; | ||
| comment?: { id?: string; body?: string; [key: string]: unknown }; | ||
| notification?: LinearAppUserNotificationPayload['notification']; | ||
| }; | ||
|
|
||
| export type LinearAgentSessionEvent = | ||
| | (Omit<WorkforceProviderEvent, 'payload' | 'source' | 'type'> & { | ||
| source: 'linear'; | ||
| type: 'AgentSessionEvent.created' | 'AgentSessionEvent.prompted'; | ||
| payload: LinearAgentSessionEventPayload; | ||
| }) | ||
| | (Omit<WorkforceProviderEvent, 'payload' | 'source' | 'type'> & { | ||
| source: 'linear'; | ||
| type: 'AppUserNotification.issueCommentMention'; | ||
| payload: LinearAppUserNotificationEventPayload; | ||
| }); | ||
|
|
||
| export type WorkforceEvent = WorkforceCronEvent | LinearAgentSessionEvent | WorkforceProviderEvent; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: This union includes both a specialized Linear event type and the broad Severity Level: Major
|
||
|
|
||
| function isRecord(value: unknown): value is Record<string, unknown> { | ||
| return typeof value === 'object' && value !== null; | ||
| } | ||
|
|
||
| /** | ||
| * Result of a harness invocation. The runtime translates whatever the | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The generic return type is effectively lost because
T | unknownalways collapses tounknown, so callers never get the typed result they requested fromunwrapResourceRecord<T>(...). Change the signature to returnT(orT | undefinedif needed) so the helper preserves the generic contract. [api mismatch]Severity Level: Major⚠️
Steps of Reproduction ✅
Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖