@extrovert.dev/sdk 0.1.0-pre.7 → 0.1.0-pre.8

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/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@
6
6
  * on 429/5xx, honors `Retry-After`, and surfaces every failure as a typed {@link ApiError}.
7
7
  */
8
8
  /** The library version, surfaced in the User-Agent. Kept in sync with package.json by build. */
9
- declare const SDK_VERSION = "0.1.0-pre.7";
9
+ declare const SDK_VERSION = "0.1.0-pre.8";
10
10
  interface RetryOptions {
11
11
  /** Max retry attempts for idempotent requests on 429/5xx/network errors. Default 2. */
12
12
  maxRetries: number;
@@ -781,6 +781,7 @@ interface ReviewTurn {
781
781
  }
782
782
  /** Filters for listing review requests (spec §5.2). */
783
783
  interface ListReviewsParams {
784
+ composer?: "me";
784
785
  state?: ReviewState | ReviewState[];
785
786
  category_id?: string;
786
787
  inbox?: string;
@@ -911,6 +912,7 @@ interface ReviewEventCursor {
911
912
  }
912
913
  /** Drain result for list/wait: un-acked events in FIFO seq order + cursors. */
913
914
  interface ReviewEventsResult {
915
+ pending_reviews?: number;
914
916
  events: ReviewEvent[];
915
917
  cursors?: ReviewEventCursor[];
916
918
  }
@@ -1207,6 +1209,8 @@ interface Rule {
1207
1209
  author_kind: "agent" | "human";
1208
1210
  created_at: IsoTimestamp;
1209
1211
  updated_at: IsoTimestamp;
1212
+ source_review_id?: string;
1213
+ source_turn_id?: string;
1210
1214
  }
1211
1215
  /** Filter for the ordered get_rules read (spec §5.4; §7). */
1212
1216
  interface GetRulesParams {
@@ -1891,6 +1895,24 @@ interface WhoAmI {
1891
1895
  key_id: string;
1892
1896
  scopes: Scope[];
1893
1897
  }
1898
+ /** Learn writing guidance from an authenticated human turn on your review. */
1899
+ interface LearnReviewRuleRequest {
1900
+ client_id: string;
1901
+ source_turn_id: string;
1902
+ rule_text: string;
1903
+ target: "org_house" | "project_general" | "category";
1904
+ category_id?: string;
1905
+ kind?: "soft" | "hard";
1906
+ supersedes_id?: string;
1907
+ }
1908
+ interface LearnedReviewRule {
1909
+ rule: Rule;
1910
+ source_review_id: string;
1911
+ source_turn_id: string;
1912
+ human_id: string;
1913
+ audit_id: string;
1914
+ propagation: "queued";
1915
+ }
1894
1916
 
1895
1917
  /**
1896
1918
  * The ONE list envelope + opaque-cursor iteration (redesign §5.2 / §6.2).
@@ -2067,6 +2089,7 @@ interface Transport {
2067
2089
  getScanBacklogStatus(categoryId: string, signal?: AbortSignal): Promise<ScanBacklogStatus>;
2068
2090
  getCategoryPacingState(categoryId: string, signal?: AbortSignal): Promise<CategoryPacingState>;
2069
2091
  getRules(params: GetRulesParams, signal?: AbortSignal): Promise<RuleSnapshot>;
2092
+ learnReviewRule(reviewId: string, req: LearnReviewRuleRequest, signal?: AbortSignal): Promise<LearnedReviewRule>;
2070
2093
  saveRule(req: SaveRuleRequest, signal?: AbortSignal): Promise<Rule>;
2071
2094
  promoteRule(ruleId: string, toScope: "general" | "category", signal?: AbortSignal): Promise<Rule>;
2072
2095
  retireRule(ruleId: string, signal?: AbortSignal): Promise<Rule>;
@@ -2287,6 +2310,8 @@ declare class MockBackend {
2287
2310
  /** Get the ORDERED active rule set (mock) - §7 ladder + category-before-general. */
2288
2311
  getRules(params?: GetRulesParams): RuleSnapshot;
2289
2312
  /** Save / edit a rule (mock) - append-only by supersession (D11). */
2313
+ private learnedRules;
2314
+ learnReviewRule(reviewId: string, req: LearnReviewRuleRequest): LearnedReviewRule;
2290
2315
  saveRule(req: SaveRuleRequest): Rule;
2291
2316
  /** Promote a rule between layers (mock, via supersession), or undefined when unknown. */
2292
2317
  promoteRule(ruleId: string, toScope: "general" | "category"): Rule | undefined;
@@ -3253,13 +3278,15 @@ declare class Categories {
3253
3278
  */
3254
3279
  declare class Rules {
3255
3280
  private readonly ctx;
3281
+ /** Learn category or organization house rules from verified human review feedback. */
3282
+ learnFromReview(reviewId: string, req: LearnReviewRuleRequest, signal?: AbortSignal): Promise<LearnedReviewRule>;
3256
3283
  constructor(ctx: ResourceContext);
3257
3284
  /** Get the ORDERED active rule set (precedence ladder applied; NO LLM). */
3258
3285
  get(params?: GetRulesParams, signal?: AbortSignal): Promise<RuleSnapshot>;
3259
3286
  /**
3260
3287
  * Save / edit a rule (append-only by supersession; D11). An agent-plane save is
3261
3288
  * ALWAYS project-layer: the saved rule's `rule_layer` is `project`, bound to the
3262
- * key's project. Agents cannot author org-layer / house-style (`rule_layer:"org"`)
3289
+ * key's project. For org-layer house rules use learnFromReview with an authenticated human source; this method cannot author (`rule_layer:"org"`)
3263
3290
  * rules in v1: that is a console/admin action.
3264
3291
  */
3265
3292
  save(req: SaveRuleRequest, signal?: AbortSignal): Promise<Rule>;
@@ -3963,7 +3990,7 @@ declare function signWebhook(secret: string, body: string, timestampSeconds: num
3963
3990
  *
3964
3991
  * ## Provisional, pre-1.0 (0.x)
3965
3992
  *
3966
- * {@link CONTRACT_VERSION} is **`0.1.0-pre.7`** - a deliberately **provisional**, pre-1.0
3993
+ * {@link CONTRACT_VERSION} is **`0.1.0-pre.8`** - a deliberately **provisional**, pre-1.0
3967
3994
  * contract. It is open and documented, but it MAY still evolve before 1.0: there
3968
3995
  * are no external users yet, and the **D20 shared-pool auto-send governor** is a
3969
3996
  * hard prerequisite before onboarding external users. Pin the version; expect
@@ -4020,12 +4047,12 @@ interface DiffJson {
4020
4047
  /**
4021
4048
  * The published version of the Extrovert Review-Loop open contract (D14).
4022
4049
  *
4023
- * **`0.1.0-pre.7` - PROVISIONAL, pre-1.0.** Versioned *with the SDK* (this package's
4050
+ * **`0.1.0-pre.8` - PROVISIONAL, pre-1.0.** Versioned *with the SDK* (this package's
4024
4051
  * `package.json` version) and aligned to the openapi `info.version`. Open and
4025
4052
  * documented, but MAY still evolve before 1.0 (no external users yet; the D20
4026
4053
  * shared-pool governor is required before external users). Pin it.
4027
4054
  */
4028
- declare const CONTRACT_VERSION: "0.1.0-pre.7";
4055
+ declare const CONTRACT_VERSION: "0.1.0-pre.8";
4029
4056
  /** The stability posture of a published contract version. */
4030
4057
  type ContractStability = "provisional" | "stable";
4031
4058
  /**
@@ -4068,4 +4095,4 @@ interface ContractManifest {
4068
4095
  */
4069
4096
  declare const CONTRACT_MANIFEST: ContractManifest;
4070
4097
 
4071
- export { API_VERSION_HEADER, type AccountRiskDial, type AckReviewEventEntry, type AckReviewEventRequest, type AckReviewEventResult, type AddContactListRequest, type Agent, type AgentStatus, ApiError, type ApiErrorBody, type Attachment, type AttachmentDownload, type AttachmentInput, AuthenticationError, type BatchUpdateMessagesRequest, type BatchUpdateResult, BornStaleError, BreadthRequiredError, CONTRACT_MANIFEST, CONTRACT_VERSION, CURRENT_API_VERSION, Categories, type Category, type CategoryPacingState, type CategoryRiskDial, Commerce, type CommerceBlocker, type CommerceRequest, type CommerceRequestKind, ConflictError, ConnectionError, type ContactListDirection, type ContactListEntry, type ContactListKind, ContactLists, type ContractManifest, type ContractStability, type CreateInboxRequest, type Cursor, DEFAULT_BASE_URL, type DeleteResult, type DiffHunk, type DiffJson, type Domain, type DomainOffboard, type DomainQuote, type DomainReadiness, type DomainRecord, type DomainScope, type DomainStatusEvent, type DomainStatusEventPage, type DomainWaitResult, Domains, type EffectiveRiskDial, type EmailAddress, type EnrollRequest, type EnrollResponse, type ExtractedCredentials, ExtrovertClient as Extrovert, ExtrovertClient, type ExtrovertClientOptions, ForbiddenScopeError, type ForwardRequest, type GetInboxParams, type GetRuleAuditParams, type GetRulesParams, type GraduationStatus, IdempotencyConflictError, type Inbox, type InboxCredentials, InboxHandle, type InboxInclude, type InboxMetadata, type InboxMetadataPatch, type InboxMetadataValue, type InboxStatus, Inboxes, IntentRequiredError, type IsoTimestamp, type Job, type KeyTier, type List, type ListCategoriesParams, type ListCommerceRequestsParams, type ListInboxesParams, type ListMessagesParams, ListPage, type ListParams, type ListReviewEventsParams, type ListReviewsParams, type ListSuppressionsParams, type ListThreadsParams, MOCK_BASE_URL, type MailFolder, type MailboxQuickstart, type MailboxQuickstartCall, type MarkReadRequest, type Message, type MessageDirection, Messages, MockBackend, NotFoundError, type OnboardDomainRequest, type OnboardingMode, PROBLEM_CODES, type PacingItem, type Page, type PageFetcher, PaymentRequiredError, PermissionError, type PostReviewChatRequest, type Problem, type ProblemCode, type ProblemField, type ProjectInboxListParams, ProjectInboxes, Projects, type ProposeCategoryRequest, type ProposeGraduationRequest, type QueuedForReviewResult, type QuoteDomainRequest, REVIEW_PROBLEM_RETRYABLE, RateLimitError, RecipientSuppressedError, type RegisterWebhookRequest, type ReplyRequest, type RequestDomainPurchaseRequest, type RequestPlanChangeRequest, type RestampReviewRequest, type Review, ReviewConflictError, type ReviewDecisionContext, type ReviewEvent, type ReviewEventCursor, type ReviewEventReason, ReviewEvents, type ReviewEventsResult, type ReviewFeedback, type ReviewFeedbackComment, type ReviewInclude, type ReviewIntent, type ReviewMode, type ReviewPolicy, type ReviewState, type ReviewTurn, type ReviewerAction, type ReviewerDecisionRequest, type ReviewerDecisionResult, Reviews, type RiskDial, type Rule, type RuleAuditEntry, type RuleLayer, type RuleSnapshot, Rules, SDK_VERSION, type SaveRuleRequest, type ScanBacklogStatus, type Scope, type SearchMessagesParams, SendNeedsReconciliationError, type SendOutcome, type SendRequest, type SendResult, type SentResult, type SignUpRequest, type SignUpResponse, StaleError, type StreamEvent, type StreamOptions, type SubmitForReviewResult, type SubmitRevisionRequest, type SuppressionEntry, type SuppressionPrecheck, type SuppressionScope, type SuppressionSource, Suppressions, TerminalError, type Thread, type ThreadDetail, Threads, TimeoutError, UnavailableError, type UpdateCategoryRequest, type UpdateInboxRequest, type UpdateWebhookRequest, ValidationError, type VerifyRequest, type VerifyResponse, type VerifyWebhookOptions, type WaitForEmailRequest, type WaitForEmailResult, type WaitForReviewEventParams, type Webhook, type WebhookEvent, type WebhookPayload, Webhooks, type WhoAmI, WrongStateError, extractCredentials, extractLink, extractOtp, isProblemCode, isQueuedForReview, isSentImmediately, listPage, parseKeyTier, parseProblem, parseWebhook, reviewIdOf, sentMessageIdOf, serializeInclude, signWebhook, threadIdOf, tierAllowsOrgWildcard, tierNeedsExplicitBreadth, verifyWebhookSignature };
4098
+ export { API_VERSION_HEADER, type AccountRiskDial, type AckReviewEventEntry, type AckReviewEventRequest, type AckReviewEventResult, type AddContactListRequest, type Agent, type AgentStatus, ApiError, type ApiErrorBody, type Attachment, type AttachmentDownload, type AttachmentInput, AuthenticationError, type BatchUpdateMessagesRequest, type BatchUpdateResult, BornStaleError, BreadthRequiredError, CONTRACT_MANIFEST, CONTRACT_VERSION, CURRENT_API_VERSION, Categories, type Category, type CategoryPacingState, type CategoryRiskDial, Commerce, type CommerceBlocker, type CommerceRequest, type CommerceRequestKind, ConflictError, ConnectionError, type ContactListDirection, type ContactListEntry, type ContactListKind, ContactLists, type ContractManifest, type ContractStability, type CreateInboxRequest, type Cursor, DEFAULT_BASE_URL, type DeleteResult, type DiffHunk, type DiffJson, type Domain, type DomainOffboard, type DomainQuote, type DomainReadiness, type DomainRecord, type DomainScope, type DomainStatusEvent, type DomainStatusEventPage, type DomainWaitResult, Domains, type EffectiveRiskDial, type EmailAddress, type EnrollRequest, type EnrollResponse, type ExtractedCredentials, ExtrovertClient as Extrovert, ExtrovertClient, type ExtrovertClientOptions, ForbiddenScopeError, type ForwardRequest, type GetInboxParams, type GetRuleAuditParams, type GetRulesParams, type GraduationStatus, IdempotencyConflictError, type Inbox, type InboxCredentials, InboxHandle, type InboxInclude, type InboxMetadata, type InboxMetadataPatch, type InboxMetadataValue, type InboxStatus, Inboxes, IntentRequiredError, type IsoTimestamp, type Job, type KeyTier, type LearnReviewRuleRequest, type LearnedReviewRule, type List, type ListCategoriesParams, type ListCommerceRequestsParams, type ListInboxesParams, type ListMessagesParams, ListPage, type ListParams, type ListReviewEventsParams, type ListReviewsParams, type ListSuppressionsParams, type ListThreadsParams, MOCK_BASE_URL, type MailFolder, type MailboxQuickstart, type MailboxQuickstartCall, type MarkReadRequest, type Message, type MessageDirection, Messages, MockBackend, NotFoundError, type OnboardDomainRequest, type OnboardingMode, PROBLEM_CODES, type PacingItem, type Page, type PageFetcher, PaymentRequiredError, PermissionError, type PostReviewChatRequest, type Problem, type ProblemCode, type ProblemField, type ProjectInboxListParams, ProjectInboxes, Projects, type ProposeCategoryRequest, type ProposeGraduationRequest, type QueuedForReviewResult, type QuoteDomainRequest, REVIEW_PROBLEM_RETRYABLE, RateLimitError, RecipientSuppressedError, type RegisterWebhookRequest, type ReplyRequest, type RequestDomainPurchaseRequest, type RequestPlanChangeRequest, type RestampReviewRequest, type Review, ReviewConflictError, type ReviewDecisionContext, type ReviewEvent, type ReviewEventCursor, type ReviewEventReason, ReviewEvents, type ReviewEventsResult, type ReviewFeedback, type ReviewFeedbackComment, type ReviewInclude, type ReviewIntent, type ReviewMode, type ReviewPolicy, type ReviewState, type ReviewTurn, type ReviewerAction, type ReviewerDecisionRequest, type ReviewerDecisionResult, Reviews, type RiskDial, type Rule, type RuleAuditEntry, type RuleLayer, type RuleSnapshot, Rules, SDK_VERSION, type SaveRuleRequest, type ScanBacklogStatus, type Scope, type SearchMessagesParams, SendNeedsReconciliationError, type SendOutcome, type SendRequest, type SendResult, type SentResult, type SignUpRequest, type SignUpResponse, StaleError, type StreamEvent, type StreamOptions, type SubmitForReviewResult, type SubmitRevisionRequest, type SuppressionEntry, type SuppressionPrecheck, type SuppressionScope, type SuppressionSource, Suppressions, TerminalError, type Thread, type ThreadDetail, Threads, TimeoutError, UnavailableError, type UpdateCategoryRequest, type UpdateInboxRequest, type UpdateWebhookRequest, ValidationError, type VerifyRequest, type VerifyResponse, type VerifyWebhookOptions, type WaitForEmailRequest, type WaitForEmailResult, type WaitForReviewEventParams, type Webhook, type WebhookEvent, type WebhookPayload, Webhooks, type WhoAmI, WrongStateError, extractCredentials, extractLink, extractOtp, isProblemCode, isQueuedForReview, isSentImmediately, listPage, parseKeyTier, parseProblem, parseWebhook, reviewIdOf, sentMessageIdOf, serializeInclude, signWebhook, threadIdOf, tierAllowsOrgWildcard, tierNeedsExplicitBreadth, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * on 429/5xx, honors `Retry-After`, and surfaces every failure as a typed {@link ApiError}.
7
7
  */
8
8
  /** The library version, surfaced in the User-Agent. Kept in sync with package.json by build. */
9
- declare const SDK_VERSION = "0.1.0-pre.7";
9
+ declare const SDK_VERSION = "0.1.0-pre.8";
10
10
  interface RetryOptions {
11
11
  /** Max retry attempts for idempotent requests on 429/5xx/network errors. Default 2. */
12
12
  maxRetries: number;
@@ -781,6 +781,7 @@ interface ReviewTurn {
781
781
  }
782
782
  /** Filters for listing review requests (spec §5.2). */
783
783
  interface ListReviewsParams {
784
+ composer?: "me";
784
785
  state?: ReviewState | ReviewState[];
785
786
  category_id?: string;
786
787
  inbox?: string;
@@ -911,6 +912,7 @@ interface ReviewEventCursor {
911
912
  }
912
913
  /** Drain result for list/wait: un-acked events in FIFO seq order + cursors. */
913
914
  interface ReviewEventsResult {
915
+ pending_reviews?: number;
914
916
  events: ReviewEvent[];
915
917
  cursors?: ReviewEventCursor[];
916
918
  }
@@ -1207,6 +1209,8 @@ interface Rule {
1207
1209
  author_kind: "agent" | "human";
1208
1210
  created_at: IsoTimestamp;
1209
1211
  updated_at: IsoTimestamp;
1212
+ source_review_id?: string;
1213
+ source_turn_id?: string;
1210
1214
  }
1211
1215
  /** Filter for the ordered get_rules read (spec §5.4; §7). */
1212
1216
  interface GetRulesParams {
@@ -1891,6 +1895,24 @@ interface WhoAmI {
1891
1895
  key_id: string;
1892
1896
  scopes: Scope[];
1893
1897
  }
1898
+ /** Learn writing guidance from an authenticated human turn on your review. */
1899
+ interface LearnReviewRuleRequest {
1900
+ client_id: string;
1901
+ source_turn_id: string;
1902
+ rule_text: string;
1903
+ target: "org_house" | "project_general" | "category";
1904
+ category_id?: string;
1905
+ kind?: "soft" | "hard";
1906
+ supersedes_id?: string;
1907
+ }
1908
+ interface LearnedReviewRule {
1909
+ rule: Rule;
1910
+ source_review_id: string;
1911
+ source_turn_id: string;
1912
+ human_id: string;
1913
+ audit_id: string;
1914
+ propagation: "queued";
1915
+ }
1894
1916
 
1895
1917
  /**
1896
1918
  * The ONE list envelope + opaque-cursor iteration (redesign §5.2 / §6.2).
@@ -2067,6 +2089,7 @@ interface Transport {
2067
2089
  getScanBacklogStatus(categoryId: string, signal?: AbortSignal): Promise<ScanBacklogStatus>;
2068
2090
  getCategoryPacingState(categoryId: string, signal?: AbortSignal): Promise<CategoryPacingState>;
2069
2091
  getRules(params: GetRulesParams, signal?: AbortSignal): Promise<RuleSnapshot>;
2092
+ learnReviewRule(reviewId: string, req: LearnReviewRuleRequest, signal?: AbortSignal): Promise<LearnedReviewRule>;
2070
2093
  saveRule(req: SaveRuleRequest, signal?: AbortSignal): Promise<Rule>;
2071
2094
  promoteRule(ruleId: string, toScope: "general" | "category", signal?: AbortSignal): Promise<Rule>;
2072
2095
  retireRule(ruleId: string, signal?: AbortSignal): Promise<Rule>;
@@ -2287,6 +2310,8 @@ declare class MockBackend {
2287
2310
  /** Get the ORDERED active rule set (mock) - §7 ladder + category-before-general. */
2288
2311
  getRules(params?: GetRulesParams): RuleSnapshot;
2289
2312
  /** Save / edit a rule (mock) - append-only by supersession (D11). */
2313
+ private learnedRules;
2314
+ learnReviewRule(reviewId: string, req: LearnReviewRuleRequest): LearnedReviewRule;
2290
2315
  saveRule(req: SaveRuleRequest): Rule;
2291
2316
  /** Promote a rule between layers (mock, via supersession), or undefined when unknown. */
2292
2317
  promoteRule(ruleId: string, toScope: "general" | "category"): Rule | undefined;
@@ -3253,13 +3278,15 @@ declare class Categories {
3253
3278
  */
3254
3279
  declare class Rules {
3255
3280
  private readonly ctx;
3281
+ /** Learn category or organization house rules from verified human review feedback. */
3282
+ learnFromReview(reviewId: string, req: LearnReviewRuleRequest, signal?: AbortSignal): Promise<LearnedReviewRule>;
3256
3283
  constructor(ctx: ResourceContext);
3257
3284
  /** Get the ORDERED active rule set (precedence ladder applied; NO LLM). */
3258
3285
  get(params?: GetRulesParams, signal?: AbortSignal): Promise<RuleSnapshot>;
3259
3286
  /**
3260
3287
  * Save / edit a rule (append-only by supersession; D11). An agent-plane save is
3261
3288
  * ALWAYS project-layer: the saved rule's `rule_layer` is `project`, bound to the
3262
- * key's project. Agents cannot author org-layer / house-style (`rule_layer:"org"`)
3289
+ * key's project. For org-layer house rules use learnFromReview with an authenticated human source; this method cannot author (`rule_layer:"org"`)
3263
3290
  * rules in v1: that is a console/admin action.
3264
3291
  */
3265
3292
  save(req: SaveRuleRequest, signal?: AbortSignal): Promise<Rule>;
@@ -3963,7 +3990,7 @@ declare function signWebhook(secret: string, body: string, timestampSeconds: num
3963
3990
  *
3964
3991
  * ## Provisional, pre-1.0 (0.x)
3965
3992
  *
3966
- * {@link CONTRACT_VERSION} is **`0.1.0-pre.7`** - a deliberately **provisional**, pre-1.0
3993
+ * {@link CONTRACT_VERSION} is **`0.1.0-pre.8`** - a deliberately **provisional**, pre-1.0
3967
3994
  * contract. It is open and documented, but it MAY still evolve before 1.0: there
3968
3995
  * are no external users yet, and the **D20 shared-pool auto-send governor** is a
3969
3996
  * hard prerequisite before onboarding external users. Pin the version; expect
@@ -4020,12 +4047,12 @@ interface DiffJson {
4020
4047
  /**
4021
4048
  * The published version of the Extrovert Review-Loop open contract (D14).
4022
4049
  *
4023
- * **`0.1.0-pre.7` - PROVISIONAL, pre-1.0.** Versioned *with the SDK* (this package's
4050
+ * **`0.1.0-pre.8` - PROVISIONAL, pre-1.0.** Versioned *with the SDK* (this package's
4024
4051
  * `package.json` version) and aligned to the openapi `info.version`. Open and
4025
4052
  * documented, but MAY still evolve before 1.0 (no external users yet; the D20
4026
4053
  * shared-pool governor is required before external users). Pin it.
4027
4054
  */
4028
- declare const CONTRACT_VERSION: "0.1.0-pre.7";
4055
+ declare const CONTRACT_VERSION: "0.1.0-pre.8";
4029
4056
  /** The stability posture of a published contract version. */
4030
4057
  type ContractStability = "provisional" | "stable";
4031
4058
  /**
@@ -4068,4 +4095,4 @@ interface ContractManifest {
4068
4095
  */
4069
4096
  declare const CONTRACT_MANIFEST: ContractManifest;
4070
4097
 
4071
- export { API_VERSION_HEADER, type AccountRiskDial, type AckReviewEventEntry, type AckReviewEventRequest, type AckReviewEventResult, type AddContactListRequest, type Agent, type AgentStatus, ApiError, type ApiErrorBody, type Attachment, type AttachmentDownload, type AttachmentInput, AuthenticationError, type BatchUpdateMessagesRequest, type BatchUpdateResult, BornStaleError, BreadthRequiredError, CONTRACT_MANIFEST, CONTRACT_VERSION, CURRENT_API_VERSION, Categories, type Category, type CategoryPacingState, type CategoryRiskDial, Commerce, type CommerceBlocker, type CommerceRequest, type CommerceRequestKind, ConflictError, ConnectionError, type ContactListDirection, type ContactListEntry, type ContactListKind, ContactLists, type ContractManifest, type ContractStability, type CreateInboxRequest, type Cursor, DEFAULT_BASE_URL, type DeleteResult, type DiffHunk, type DiffJson, type Domain, type DomainOffboard, type DomainQuote, type DomainReadiness, type DomainRecord, type DomainScope, type DomainStatusEvent, type DomainStatusEventPage, type DomainWaitResult, Domains, type EffectiveRiskDial, type EmailAddress, type EnrollRequest, type EnrollResponse, type ExtractedCredentials, ExtrovertClient as Extrovert, ExtrovertClient, type ExtrovertClientOptions, ForbiddenScopeError, type ForwardRequest, type GetInboxParams, type GetRuleAuditParams, type GetRulesParams, type GraduationStatus, IdempotencyConflictError, type Inbox, type InboxCredentials, InboxHandle, type InboxInclude, type InboxMetadata, type InboxMetadataPatch, type InboxMetadataValue, type InboxStatus, Inboxes, IntentRequiredError, type IsoTimestamp, type Job, type KeyTier, type List, type ListCategoriesParams, type ListCommerceRequestsParams, type ListInboxesParams, type ListMessagesParams, ListPage, type ListParams, type ListReviewEventsParams, type ListReviewsParams, type ListSuppressionsParams, type ListThreadsParams, MOCK_BASE_URL, type MailFolder, type MailboxQuickstart, type MailboxQuickstartCall, type MarkReadRequest, type Message, type MessageDirection, Messages, MockBackend, NotFoundError, type OnboardDomainRequest, type OnboardingMode, PROBLEM_CODES, type PacingItem, type Page, type PageFetcher, PaymentRequiredError, PermissionError, type PostReviewChatRequest, type Problem, type ProblemCode, type ProblemField, type ProjectInboxListParams, ProjectInboxes, Projects, type ProposeCategoryRequest, type ProposeGraduationRequest, type QueuedForReviewResult, type QuoteDomainRequest, REVIEW_PROBLEM_RETRYABLE, RateLimitError, RecipientSuppressedError, type RegisterWebhookRequest, type ReplyRequest, type RequestDomainPurchaseRequest, type RequestPlanChangeRequest, type RestampReviewRequest, type Review, ReviewConflictError, type ReviewDecisionContext, type ReviewEvent, type ReviewEventCursor, type ReviewEventReason, ReviewEvents, type ReviewEventsResult, type ReviewFeedback, type ReviewFeedbackComment, type ReviewInclude, type ReviewIntent, type ReviewMode, type ReviewPolicy, type ReviewState, type ReviewTurn, type ReviewerAction, type ReviewerDecisionRequest, type ReviewerDecisionResult, Reviews, type RiskDial, type Rule, type RuleAuditEntry, type RuleLayer, type RuleSnapshot, Rules, SDK_VERSION, type SaveRuleRequest, type ScanBacklogStatus, type Scope, type SearchMessagesParams, SendNeedsReconciliationError, type SendOutcome, type SendRequest, type SendResult, type SentResult, type SignUpRequest, type SignUpResponse, StaleError, type StreamEvent, type StreamOptions, type SubmitForReviewResult, type SubmitRevisionRequest, type SuppressionEntry, type SuppressionPrecheck, type SuppressionScope, type SuppressionSource, Suppressions, TerminalError, type Thread, type ThreadDetail, Threads, TimeoutError, UnavailableError, type UpdateCategoryRequest, type UpdateInboxRequest, type UpdateWebhookRequest, ValidationError, type VerifyRequest, type VerifyResponse, type VerifyWebhookOptions, type WaitForEmailRequest, type WaitForEmailResult, type WaitForReviewEventParams, type Webhook, type WebhookEvent, type WebhookPayload, Webhooks, type WhoAmI, WrongStateError, extractCredentials, extractLink, extractOtp, isProblemCode, isQueuedForReview, isSentImmediately, listPage, parseKeyTier, parseProblem, parseWebhook, reviewIdOf, sentMessageIdOf, serializeInclude, signWebhook, threadIdOf, tierAllowsOrgWildcard, tierNeedsExplicitBreadth, verifyWebhookSignature };
4098
+ export { API_VERSION_HEADER, type AccountRiskDial, type AckReviewEventEntry, type AckReviewEventRequest, type AckReviewEventResult, type AddContactListRequest, type Agent, type AgentStatus, ApiError, type ApiErrorBody, type Attachment, type AttachmentDownload, type AttachmentInput, AuthenticationError, type BatchUpdateMessagesRequest, type BatchUpdateResult, BornStaleError, BreadthRequiredError, CONTRACT_MANIFEST, CONTRACT_VERSION, CURRENT_API_VERSION, Categories, type Category, type CategoryPacingState, type CategoryRiskDial, Commerce, type CommerceBlocker, type CommerceRequest, type CommerceRequestKind, ConflictError, ConnectionError, type ContactListDirection, type ContactListEntry, type ContactListKind, ContactLists, type ContractManifest, type ContractStability, type CreateInboxRequest, type Cursor, DEFAULT_BASE_URL, type DeleteResult, type DiffHunk, type DiffJson, type Domain, type DomainOffboard, type DomainQuote, type DomainReadiness, type DomainRecord, type DomainScope, type DomainStatusEvent, type DomainStatusEventPage, type DomainWaitResult, Domains, type EffectiveRiskDial, type EmailAddress, type EnrollRequest, type EnrollResponse, type ExtractedCredentials, ExtrovertClient as Extrovert, ExtrovertClient, type ExtrovertClientOptions, ForbiddenScopeError, type ForwardRequest, type GetInboxParams, type GetRuleAuditParams, type GetRulesParams, type GraduationStatus, IdempotencyConflictError, type Inbox, type InboxCredentials, InboxHandle, type InboxInclude, type InboxMetadata, type InboxMetadataPatch, type InboxMetadataValue, type InboxStatus, Inboxes, IntentRequiredError, type IsoTimestamp, type Job, type KeyTier, type LearnReviewRuleRequest, type LearnedReviewRule, type List, type ListCategoriesParams, type ListCommerceRequestsParams, type ListInboxesParams, type ListMessagesParams, ListPage, type ListParams, type ListReviewEventsParams, type ListReviewsParams, type ListSuppressionsParams, type ListThreadsParams, MOCK_BASE_URL, type MailFolder, type MailboxQuickstart, type MailboxQuickstartCall, type MarkReadRequest, type Message, type MessageDirection, Messages, MockBackend, NotFoundError, type OnboardDomainRequest, type OnboardingMode, PROBLEM_CODES, type PacingItem, type Page, type PageFetcher, PaymentRequiredError, PermissionError, type PostReviewChatRequest, type Problem, type ProblemCode, type ProblemField, type ProjectInboxListParams, ProjectInboxes, Projects, type ProposeCategoryRequest, type ProposeGraduationRequest, type QueuedForReviewResult, type QuoteDomainRequest, REVIEW_PROBLEM_RETRYABLE, RateLimitError, RecipientSuppressedError, type RegisterWebhookRequest, type ReplyRequest, type RequestDomainPurchaseRequest, type RequestPlanChangeRequest, type RestampReviewRequest, type Review, ReviewConflictError, type ReviewDecisionContext, type ReviewEvent, type ReviewEventCursor, type ReviewEventReason, ReviewEvents, type ReviewEventsResult, type ReviewFeedback, type ReviewFeedbackComment, type ReviewInclude, type ReviewIntent, type ReviewMode, type ReviewPolicy, type ReviewState, type ReviewTurn, type ReviewerAction, type ReviewerDecisionRequest, type ReviewerDecisionResult, Reviews, type RiskDial, type Rule, type RuleAuditEntry, type RuleLayer, type RuleSnapshot, Rules, SDK_VERSION, type SaveRuleRequest, type ScanBacklogStatus, type Scope, type SearchMessagesParams, SendNeedsReconciliationError, type SendOutcome, type SendRequest, type SendResult, type SentResult, type SignUpRequest, type SignUpResponse, StaleError, type StreamEvent, type StreamOptions, type SubmitForReviewResult, type SubmitRevisionRequest, type SuppressionEntry, type SuppressionPrecheck, type SuppressionScope, type SuppressionSource, Suppressions, TerminalError, type Thread, type ThreadDetail, Threads, TimeoutError, UnavailableError, type UpdateCategoryRequest, type UpdateInboxRequest, type UpdateWebhookRequest, ValidationError, type VerifyRequest, type VerifyResponse, type VerifyWebhookOptions, type WaitForEmailRequest, type WaitForEmailResult, type WaitForReviewEventParams, type Webhook, type WebhookEvent, type WebhookPayload, Webhooks, type WhoAmI, WrongStateError, extractCredentials, extractLink, extractOtp, isProblemCode, isQueuedForReview, isSentImmediately, listPage, parseKeyTier, parseProblem, parseWebhook, reviewIdOf, sentMessageIdOf, serializeInclude, signWebhook, threadIdOf, tierAllowsOrgWildcard, tierNeedsExplicitBreadth, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -266,7 +266,7 @@ var CURRENT_API_VERSION = "2026-06-23";
266
266
  var API_VERSION_HEADER = "Extrovert-Version";
267
267
 
268
268
  // src/http.ts
269
- var SDK_VERSION = "0.1.0-pre.7";
269
+ var SDK_VERSION = "0.1.0-pre.8";
270
270
  function buildUrl(baseUrl, path, query) {
271
271
  const base = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
272
272
  const rel = path.startsWith("/") ? path : `/${path}`;
@@ -936,6 +936,8 @@ ${parent.text}`;
936
936
  var MockBackend = class {
937
937
  constructor() {
938
938
  this.state = freshState();
939
+ /** Save / edit a rule (mock) - append-only by supersession (D11). */
940
+ this.learnedRules = /* @__PURE__ */ new Map();
939
941
  }
940
942
  reset() {
941
943
  this.state = freshState();
@@ -2040,7 +2042,27 @@ var MockBackend = class {
2040
2042
  composition_token_expires_at: params.scope ? void 0 : new Date(Date.now() + 6e5).toISOString()
2041
2043
  };
2042
2044
  }
2043
- /** Save / edit a rule (mock) - append-only by supersession (D11). */
2045
+ learnReviewRule(reviewId, req) {
2046
+ const fingerprint = JSON.stringify({ reviewId, req });
2047
+ const prior = this.learnedRules.get(req.client_id);
2048
+ if (prior) {
2049
+ if (prior.fingerprint !== fingerprint) throw new ValidationError({ status: 409, code: "conflict", message: "learning retry identity changed" });
2050
+ return structuredClone(prior.result);
2051
+ }
2052
+ const turn = (this.state.reviewTurns.get(reviewId) ?? []).find((t) => t.id === req.source_turn_id);
2053
+ if (!turn || turn.actor_kind !== "human" || !turn.actor_id) throw new ValidationError({ status: 403, code: "forbidden_scope", message: "learning requires authenticated human feedback" });
2054
+ const rule = this.saveRule({ ...req, scope: req.target === "category" ? "category" : "general", source_review_id: reviewId, source_turn_id: turn.id });
2055
+ rule.source_turn_id = turn.id;
2056
+ rule.rule_layer = req.target === "org_house" ? "org" : "project";
2057
+ if (req.target === "org_house") delete rule.project_id;
2058
+ rule.source_review_id = reviewId;
2059
+ rule.source_turn_id = turn.id;
2060
+ const audit = [...this.state.ruleAudit.values()].find((entry) => entry.entity_id === rule.id);
2061
+ audit.after_json = ruleSnapshotJSON(rule);
2062
+ const result = { rule, source_review_id: reviewId, source_turn_id: turn.id, human_id: turn.actor_id, audit_id: audit.id, propagation: "queued" };
2063
+ this.learnedRules.set(req.client_id, { fingerprint, result: structuredClone(result) });
2064
+ return result;
2065
+ }
2044
2066
  saveRule(req) {
2045
2067
  const text = req.rule_text.trim();
2046
2068
  if (!text) {
@@ -3681,6 +3703,7 @@ var HttpTransport = class {
3681
3703
  state: Array.isArray(params.state) ? params.state.join(",") : params.state,
3682
3704
  category_id: params.category_id,
3683
3705
  inbox: params.inbox,
3706
+ composer: params.composer,
3684
3707
  limit: params.limit,
3685
3708
  page: params.page
3686
3709
  };
@@ -3763,10 +3786,12 @@ var HttpTransport = class {
3763
3786
  });
3764
3787
  }
3765
3788
  waitForReviewEvent(params, signal) {
3789
+ const waitSeconds = Math.min(55, Math.max(1, params.wait_seconds ?? 55));
3766
3790
  return this.call({
3767
3791
  method: "GET",
3768
3792
  path: "/v1/reviews/events/wait",
3769
- query: { review_id: params.review_id, limit: params.limit, wait_seconds: params.wait_seconds },
3793
+ query: { review_id: params.review_id, limit: params.limit, wait_seconds: waitSeconds },
3794
+ timeoutMs: (waitSeconds + 10) * 1e3,
3770
3795
  signal
3771
3796
  });
3772
3797
  }
@@ -3835,6 +3860,9 @@ var HttpTransport = class {
3835
3860
  signal
3836
3861
  });
3837
3862
  }
3863
+ learnReviewRule(reviewId, req, signal) {
3864
+ return this.call({ method: "POST", path: `/v1/reviews/${encodeURIComponent(reviewId)}/learned-rules`, body: req, signal });
3865
+ }
3838
3866
  saveRule(req, signal) {
3839
3867
  return this.call({
3840
3868
  method: "PUT",
@@ -4242,6 +4270,9 @@ var MockTransport = class {
4242
4270
  async getRules(params) {
4243
4271
  return this.backend.getRules(params);
4244
4272
  }
4273
+ async learnReviewRule(reviewId, req) {
4274
+ return this.backend.learnReviewRule(reviewId, req);
4275
+ }
4245
4276
  async saveRule(req) {
4246
4277
  return this.backend.saveRule(req);
4247
4278
  }
@@ -5271,6 +5302,10 @@ var Rules = class {
5271
5302
  constructor(ctx) {
5272
5303
  this.ctx = ctx;
5273
5304
  }
5305
+ /** Learn category or organization house rules from verified human review feedback. */
5306
+ learnFromReview(reviewId, req, signal) {
5307
+ return this.ctx.transport.learnReviewRule(reviewId, req, signal);
5308
+ }
5274
5309
  /** Get the ORDERED active rule set (precedence ladder applied; NO LLM). */
5275
5310
  get(params = {}, signal) {
5276
5311
  return this.ctx.transport.getRules(params, signal);
@@ -5278,7 +5313,7 @@ var Rules = class {
5278
5313
  /**
5279
5314
  * Save / edit a rule (append-only by supersession; D11). An agent-plane save is
5280
5315
  * ALWAYS project-layer: the saved rule's `rule_layer` is `project`, bound to the
5281
- * key's project. Agents cannot author org-layer / house-style (`rule_layer:"org"`)
5316
+ * key's project. For org-layer house rules use learnFromReview with an authenticated human source; this method cannot author (`rule_layer:"org"`)
5282
5317
  * rules in v1: that is a console/admin action.
5283
5318
  */
5284
5319
  save(req, signal) {
@@ -5556,7 +5591,7 @@ async function signWebhook(secret, body, timestampSeconds) {
5556
5591
  }
5557
5592
 
5558
5593
  // src/contract.ts
5559
- var CONTRACT_VERSION = "0.1.0-pre.7";
5594
+ var CONTRACT_VERSION = "0.1.0-pre.8";
5560
5595
  var CONTRACT_MANIFEST = {
5561
5596
  name: "extrovert.review-loop",
5562
5597
  version: CONTRACT_VERSION,
@@ -5587,6 +5622,8 @@ var CONTRACT_MANIFEST = {
5587
5622
  // realtime (M3)
5588
5623
  "ReviewEventReason",
5589
5624
  "ReviewEventsResult",
5625
+ "LearnReviewRuleRequest",
5626
+ "LearnedReviewRule",
5590
5627
  "ReviewEventCursor",
5591
5628
  // chat / revision / restamp (M5/M7)
5592
5629
  "PostReviewChatRequest",