@keemakr/operator-sdk 0.4.0 → 0.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/operator-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The keemakr connector contract: defineProvider + ConnectionProvider/ConnectionOperation types + OperationContext (governed fetch) + the connector manifest schema, shared by keemakr-core's built-in adapters and external connector repos. One shape, two consumers.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -100,6 +100,24 @@ export interface ConnectField {
100
100
  help?: string;
101
101
  }
102
102
 
103
+ // Outcome of a connect-time (or on-demand) health probe. `status` is the user-
104
+ // facing vocabulary the Hub renders: 'connected' (probe passed), 'needs_rescope'
105
+ // (OAuth completed but the granted scopes can't run this provider's operations —
106
+ // e.g. Google's granular-consent checkboxes were left unticked), 'no_mailbox'
107
+ // (the account exists but has no mailbox/service behind it — a Workspace account
108
+ // on a Microsoft-mail domain), 'unusable' (probe failed for another reason).
109
+ export interface ProbeResult {
110
+ status: 'connected' | 'needs_rescope' | 'no_mailbox' | 'unusable';
111
+ /** One human-readable sentence for the Hub's status chip. */
112
+ detail?: string;
113
+ /** Scopes the credential actually carries, when the probe can read them. */
114
+ grantedScopes?: string[];
115
+ /** Probed account identity (e.g. the mailbox email) — becomes account_label. */
116
+ accountLabel?: string | null;
117
+ /** Extra provider facts worth persisting under meta.probe. */
118
+ meta?: Record<string, unknown>;
119
+ }
120
+
103
121
  export interface ConnectionProvider {
104
122
  provider: string;
105
123
  displayName: string;
@@ -112,6 +130,29 @@ export interface ConnectionProvider {
112
130
  // Connect-path maturity. Omitted ⇒ 'ready'. See Maturity above.
113
131
  maturity?: Maturity;
114
132
 
133
+ // NOTE: a connection's scope (personal 'user' vs org-shared 'tenant') is NOT
134
+ // declared on the adapter. The live value is connections_registry.connection_mode
135
+ // (the platform-controlled overlay + rollback lever). Marketplace connectors
136
+ // seed it by declaring `connection_mode` in the MANIFEST (first publish only —
137
+ // the registry column is authoritative afterward, and reclassifying a live
138
+ // provider is a guarded staff console action). Built-ins still seed from
139
+ // registry-state's DEFAULT_USER_MODE_PROVIDERS, which stays the fail-closed
140
+ // fallback for unreadable registry reads.
141
+
142
+ // OAuth scopes this provider's operations actually NEED — unlike `scopes`
143
+ // (display-only), these are compared against the granted scope string by the
144
+ // connect-time probe; missing entries mark the connection 'needs_rescope'.
145
+ requiredScopes?: string[];
146
+
147
+ // Connect-time health probe: one cheap read (a profile fetch) that proves the
148
+ // credential can actually operate, run after the OAuth reports success and on
149
+ // demand from the Hub's "Check connection". Omitted ⇒ the connection is
150
+ // trusted as-is (status stays whatever the OAuth layer reported).
151
+ probe?(
152
+ cred: { accessToken: string; meta: Record<string, unknown> },
153
+ ctx?: OperationContext,
154
+ ): Promise<ProbeResult>;
155
+
115
156
  // Audience classification — see ConnectorSurface. Drives whether the end-user
116
157
  // client surfaces this connector and how. Optional in the type for now so
117
158
  // existing/external adapters compile through the SDK bump; defineProvider warns
@@ -204,6 +245,9 @@ export interface ConnectionProvider {
204
245
  // sees it. Keep `call` pure-ish: do the request, return JSON-serializable data.
205
246
  export interface ConnectionOperation {
206
247
  description?: string;
248
+ // Platform-only provider primitive. It remains available to trusted internal callers that
249
+ // invoke the adapter directly, but is omitted from catalogs and agent/user operation surfaces.
250
+ internal?: boolean;
207
251
  // Access class, for grant scoping + install consent. Omitted ⇒ 'write' (the
208
252
  // most restrictive assumption: unlabeled ops require the write scope and are
209
253
  // listed as writes on the consent screen).
package/src/manifest.ts CHANGED
@@ -46,6 +46,19 @@ export const connectorManifestSchema = z
46
46
  // publish gate. Optional (the adapter is authoritative); declaring it lets
47
47
  // the upload preview show it before any code runs.
48
48
  auth_kind: z.enum(['oauth2', 'api_key', 'app_password']).optional(),
49
+ // OWNERSHIP axis (orthogonal to `surface`): 'user' = each member connects
50
+ // their OWN account (one row per member, invisible to everyone else — a
51
+ // personal mailbox/drive/calendar); 'tenant' = one org-shared connection.
52
+ // Declare 'user' whenever the credential is one person's own account.
53
+ //
54
+ // Contract: this value SEEDS connections_registry.connection_mode at FIRST
55
+ // publish only — the platform column is authoritative afterward. Changing
56
+ // it in a later version raises a publish-diff warning and does NOT apply;
57
+ // live reclassification is a guarded staff console action (adopt/clean-cut).
58
+ // NEVER make this required, and never make the schema strict: stored
59
+ // manifests of already-published versions are re-parsed with the current
60
+ // schema at every publish, and only a defaulted optional field survives that.
61
+ connection_mode: z.enum(['tenant', 'user']).default('tenant'),
49
62
  // The operator-sdk contract version the connector targets (semver).
50
63
  sdk_version: z.string().regex(/^\d+\.\d+\.\d+$/, 'sdk_version must be exact semver'),
51
64
  // Module (relative path inside the bundle) whose named export is the