@hasna/contacts 0.7.0 → 0.8.1
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/README.md +83 -13
- package/dist/cli/commands/core.d.ts.map +1 -1
- package/dist/cli/index.js +82 -33
- package/dist/cloud/http-storage.d.ts +20 -12
- package/dist/cloud/http-storage.d.ts.map +1 -1
- package/dist/cloud/resolver-inputs.d.ts +51 -0
- package/dist/cloud/resolver-inputs.d.ts.map +1 -0
- package/dist/db/paths.d.ts +4 -4
- package/dist/db/paths.d.ts.map +1 -1
- package/dist/generated/storage-kit/backend.d.ts +19 -0
- package/dist/generated/storage-kit/backend.d.ts.map +1 -0
- package/dist/generated/storage-kit/index.d.ts +2 -1
- package/dist/generated/storage-kit/index.d.ts.map +1 -1
- package/dist/generated/storage-kit/migrations.d.ts +21 -0
- package/dist/generated/storage-kit/migrations.d.ts.map +1 -1
- package/dist/generated/storage-kit/own.d.ts +11 -0
- package/dist/generated/storage-kit/own.d.ts.map +1 -0
- package/dist/generated/storage-kit/pool.d.ts +5 -17
- package/dist/generated/storage-kit/pool.d.ts.map +1 -1
- package/dist/generated/storage-kit/query.d.ts +1 -1
- package/dist/generated/storage-kit/query.d.ts.map +1 -1
- package/dist/generated/storage-kit/tls.d.ts +30 -3
- package/dist/generated/storage-kit/tls.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -24
- package/dist/mcp/index.d.ts +9 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +112 -18
- package/dist/mcp/startup-gate.d.ts +48 -0
- package/dist/mcp/startup-gate.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +70 -3
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +990 -7
- package/dist/server/index.js +201 -43
- package/hasna.contract.json +20 -6
- package/package.json +3 -3
- package/dist/lib/config.d.ts +0 -7
- package/dist/lib/config.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/own.ts"],"names":[],"mappings":"AAyCA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAMtE;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1E"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import type { Pool } from "pg";
|
|
2
2
|
import { type TlsResolveOptions } from "./tls.js";
|
|
3
3
|
import { type PoolQueryClient } from "./query.js";
|
|
4
|
-
type KitEnv = Record<string, string | undefined>;
|
|
5
|
-
/** Throw when a retired storage-mode variable is set for an app. Safe to call
|
|
6
|
-
* from any server backend resolver: a no-op when no legacy key is set. */
|
|
7
|
-
export declare function assertNoRetiredStorageMode(appName: string, env?: KitEnv): void;
|
|
8
|
-
/** Resolve the Postgres DSN from the standard env aliases, never logging it. */
|
|
9
|
-
export declare function resolveDatabaseUrl(appName: string, env?: KitEnv): {
|
|
10
|
-
value: string | null;
|
|
11
|
-
source: string | null;
|
|
12
|
-
};
|
|
13
4
|
export interface CreatePgPoolOptions extends TlsResolveOptions {
|
|
14
5
|
connectionString: string;
|
|
15
6
|
/** Max clients in the pool. Defaults to pg's default (10). */
|
|
@@ -23,22 +14,19 @@ export interface CreatePgPoolOptions extends TlsResolveOptions {
|
|
|
23
14
|
}
|
|
24
15
|
/** Build a `pg.Pool` with fleet-standard TLS handling. */
|
|
25
16
|
export declare function createPgPool(options: CreatePgPoolOptions): Pool;
|
|
26
|
-
export interface
|
|
17
|
+
export interface CreateServerPoolFromEnvOptions extends TlsResolveOptions {
|
|
27
18
|
max?: number;
|
|
28
19
|
idleTimeoutMillis?: number;
|
|
29
20
|
connectionTimeoutMillis?: number;
|
|
30
21
|
applicationName?: string;
|
|
31
22
|
}
|
|
32
|
-
export interface
|
|
23
|
+
export interface ServerPoolFromEnv {
|
|
33
24
|
client: PoolQueryClient;
|
|
34
25
|
connectionSource: string;
|
|
35
26
|
}
|
|
36
27
|
/**
|
|
37
|
-
* Resolve the database URL
|
|
38
|
-
*
|
|
39
|
-
* Throws when a retired storage-mode variable is set (deployment modes no
|
|
40
|
-
* longer exist) or when the database URL is missing. Never logs the URL.
|
|
28
|
+
* Resolve the required database URL and build the server's PostgreSQL pool.
|
|
29
|
+
* Missing or invalid configuration throws without logging the URL.
|
|
41
30
|
*/
|
|
42
|
-
export declare function
|
|
43
|
-
export {};
|
|
31
|
+
export declare function createServerPoolFromEnv(appName: string, options?: CreateServerPoolFromEnvOptions): ServerPoolFromEnv;
|
|
44
32
|
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/pool.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAC;AAE3C,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAgDrE,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAmC/D;AAED,MAAM,WAAW,8BAA+B,SAAQ,iBAAiB;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,8BAAmC,GAC3C,iBAAiB,CAcnB"}
|
|
@@ -17,7 +17,7 @@ export interface PgExecutor {
|
|
|
17
17
|
export interface TypedQueryClient {
|
|
18
18
|
query<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<QueryResult<T>>;
|
|
19
19
|
many<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<T[]>;
|
|
20
|
-
/** First row or `null`. Restored here after
|
|
20
|
+
/** First row or `null`. Restored here after knowledge dropped it. */
|
|
21
21
|
get<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<T | null>;
|
|
22
22
|
/** Exactly one row; throws if zero or more than one row is returned. */
|
|
23
23
|
one<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/query.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,IAAI,EAAc,cAAc,EAAE,MAAM,IAAI,CAAC;AAE3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,cAAc;IACnD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK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passphrase?: string;
|
|
5
8
|
};
|
|
6
9
|
export interface TlsResolveOptions {
|
|
7
10
|
/** Inline CA bundle (PEM). Wins over every other CA source. */
|
|
@@ -12,15 +15,39 @@ export interface TlsResolveOptions {
|
|
|
12
15
|
env?: Record<string, string | undefined>;
|
|
13
16
|
}
|
|
14
17
|
export type SslMode = "disable" | "prefer" | "require" | "verify-ca" | "verify-full";
|
|
18
|
+
/**
|
|
19
|
+
* Remove the TLS query parameters once this module has resolved them into an
|
|
20
|
+
* explicit `ssl` option. pg re-parses `connectionString` AFTER merging pool
|
|
21
|
+
* options and lets the parse win, so leaving `sslmode` (or `ssl`, `sslcert`,
|
|
22
|
+
* `sslkey`, `sslrootcert`, `sslnegotiation`) in the URL replaces the resolved
|
|
23
|
+
* SSL object with pg's own — discarding the CA bundle with it.
|
|
24
|
+
*
|
|
25
|
+
* Non-TLS parameters and any fragment are preserved exactly.
|
|
26
|
+
*/
|
|
27
|
+
export declare function connectionStringWithoutTlsParameters(connectionString: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Preserve pg's transport negotiation choice outside the stripped URL, so
|
|
30
|
+
* `sslnegotiation=direct` survives as an explicit pool option instead of being
|
|
31
|
+
* silently dropped.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sslNegotiationFromConnectionString(connectionString: string): "postgres" | "direct" | undefined;
|
|
15
34
|
/**
|
|
16
35
|
* Extract the effective `sslmode` from a Postgres connection string. Honors the
|
|
17
|
-
* `sslmode` query param
|
|
18
|
-
*
|
|
36
|
+
* `sslmode` query param, the legacy `ssl=true` boolean, and pg's rule that
|
|
37
|
+
* `sslnegotiation=direct` implies TLS when no explicit SSL setting is present.
|
|
38
|
+
* Returns `disable` when TLS is not requested.
|
|
19
39
|
*/
|
|
20
40
|
export declare function sslModeFromConnectionString(connectionString: string): SslMode;
|
|
21
41
|
/**
|
|
22
42
|
* Resolve the `pg` ssl config for a connection string. See the module header
|
|
23
|
-
* for the full mode table.
|
|
43
|
+
* for the full mode table.
|
|
44
|
+
*
|
|
45
|
+
* Returns `false` when TLS was explicitly switched off, and `undefined` when the
|
|
46
|
+
* DSN expressed no TLS policy at all — those are different answers, and pg
|
|
47
|
+
* treats them differently: only `undefined` lets `PGSSLMODE` decide.
|
|
48
|
+
*
|
|
49
|
+
* The caller MUST hand pg `connectionStringWithoutTlsParameters(connectionString)`
|
|
50
|
+
* rather than the original DSN, or pg discards everything resolved here.
|
|
24
51
|
*/
|
|
25
52
|
export declare function resolveTlsConfig(connectionString: string, options?: TlsResolveOptions): PgSslConfig | undefined;
|
|
26
53
|
//# sourceMappingURL=tls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tls.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/tls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tls.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/tls.ts"],"names":[],"mappings":"AAwNA,iEAAiE;AACjE,MAAM,MAAM,WAAW,GACnB,OAAO,GACP;IACE,kBAAkB,EAAE,OAAO,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,aAAa,CAAC;AA+BrF;;;;;;;;GAQG;AACH,wBAAgB,oCAAoC,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAOrF;AAgBD;;;;GAIG;AACH,wBAAgB,kCAAkC,CAChD,gBAAgB,EAAE,MAAM,GACvB,UAAU,GAAG,QAAQ,GAAG,SAAS,CAKnC;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAmD7E;AA6CD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,iBAAsB,GAC9B,WAAW,GAAG,SAAS,CAgEzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { ContactProjectMembershipListResult, ContactProjectMembershipMutati
|
|
|
3
3
|
export { ContactProjectMembershipConflictError } from "./types/project-memberships.js";
|
|
4
4
|
export type { EmailType, PhoneType, AddressType, SocialPlatform, RelationshipType, ContactSource, PreferredContactMethod, ContactStatus, Sensitivity, EntityType, CompanyRelationshipType, VendorCommType, VendorCommDirection, VendorCommStatus, ApplicationType, ApplicationStatus, ApplicationMethod, DealStage, EventType, Email, Phone, Address, SocialProfile, Tag, Contact, ContactWithDetails, Company, CompanyWithDetails, ContactRelationship, CompanyRelationship, ActivityLog, Webhook, Group, CreateGroupInput, UpdateGroupInput, ContactNote, OrgMember, VendorCommunication, EscalationRule, ContactTask, Application, Deal, ContactEvent, CreateEmailInput, CreatePhoneInput, CreateAddressInput, CreateSocialProfileInput, CreateTagInput, UpdateTagInput, CreateContactInput, UpdateContactInput, ContactListOptions, CreateCompanyInput, UpdateCompanyInput, CompanyListOptions, CreateRelationshipInput, CreateCompanyRelationshipInput, CreateActivityInput, CreateWebhookInput, UpdateWebhookInput, DuplicateByEmail, DuplicateByName, CreateOrgMemberInput, UpdateOrgMemberInput, CreateVendorCommunicationInput, UpdateVendorCommunicationInput, CreateContactTaskInput, UpdateContactTaskInput, CreateApplicationInput, UpdateApplicationInput, ListApplicationsOptions, CreateDealInput, UpdateDealInput, CreateEventInput, AudienceChannel, ConsentStatus, ConsentPolicy, AudienceMatch, AudiencePredicateKind, AudiencePredicateOp, AudiencePredicateValue, AudiencePredicate, Audience, AudienceRow, CreateAudienceInput, UpdateAudienceInput, ContactConsent, ContactSuppression, AudienceRecipient, AudienceExclusion, AudienceResolution, ContactRow, CompanyRow, EmailRow, PhoneRow, AddressRow, SocialProfileRow, TagRow, RelationshipRow, ActivityRow, WebhookRow, } from "./types/index.js";
|
|
5
5
|
export { ContactNotFoundError, CompanyNotFoundError, TagNotFoundError, DuplicateTagNameError, AudienceNotFoundError, DuplicateAudienceIdError, InvalidAudienceDefinitionError, AUDIENCE_CHANNELS, CONSENT_STATUSES, CONSENT_POLICIES, } from "./types/index.js";
|
|
6
|
-
export { ContactsV1Client, ContactsV1ApiError, } from "./sdk/index.js";
|
|
7
|
-
export type { ContactsV1ClientOptions, ContactsV1Contact, ContactsV1Company, ContactsV1Tag, ContactsV1CreateContactInput, ContactsV1UpdateContactInput, ContactsV1CreateCompanyInput, ContactsV1UpdateCompanyInput, ContactsV1CreateTagInput, ContactsV1UpdateTagInput, ContactsV1ProjectMembershipSnapshot, ContactsV1ProjectMembershipMutationInput, ContactsV1ProjectMembershipMutationResult, ContactsV1ProjectMembershipListResult, } from "./sdk/index.js";
|
|
6
|
+
export { ContactsV1Client, ContactsV1ApiError, createContactsClient, contactsSdkAuthorityPinMessage, } from "./sdk/index.js";
|
|
7
|
+
export type { ContactsV1ClientOptions, CreateContactsClientOptions, ContactsV1Contact, ContactsV1Company, ContactsV1Tag, ContactsV1CreateContactInput, ContactsV1UpdateContactInput, ContactsV1CreateCompanyInput, ContactsV1UpdateCompanyInput, ContactsV1CreateTagInput, ContactsV1UpdateTagInput, ContactsV1ProjectMembershipSnapshot, ContactsV1ProjectMembershipMutationInput, ContactsV1ProjectMembershipMutationResult, ContactsV1ProjectMembershipListResult, } from "./sdk/index.js";
|
|
8
8
|
export { buildV1OpenApiDocument } from "./server/openapi.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,kCAAkC,EAClC,yCAAyC,EACzC,qCAAqC,EACrC,sCAAsC,EACtC,gCAAgC,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AAGvF,YAAY,EAEV,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,SAAS,EAET,KAAK,EACL,KAAK,EACL,OAAO,EACP,aAAa,EAEb,GAAG,EACH,OAAO,EACP,kBAAkB,EAClB,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,WAAW,EACX,IAAI,EACJ,YAAY,EAEZ,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,8BAA8B,EAC9B,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC9B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,eAAe,EACf,gBAAgB,EAEhB,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAElB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,eAAe,EACf,WAAW,EACX,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,8BAA8B,EAE9B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,kCAAkC,EAClC,yCAAyC,EACzC,qCAAqC,EACrC,sCAAsC,EACtC,gCAAgC,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AAGvF,YAAY,EAEV,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACt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AE1B,OAAO,EAEL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,8BAA8B,EAE9B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,uBAAuB,EACvB,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,mCAAmC,EACnC,wCAAwC,EACxC,yCAAyC,EACzC,qCAAqC,GACtC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/cloud/http-storage.ts
|
|
3
3
|
import {
|
|
4
|
+
ClientTransportConfigurationError,
|
|
4
5
|
createHasnaHttpTransport,
|
|
5
6
|
resolveCredential,
|
|
6
7
|
resolveClientTransport as resolveSharedClientTransport
|
|
@@ -90,6 +91,27 @@ function assertConfigurationUnchanged(env, expected) {
|
|
|
90
91
|
invalid();
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
// src/cloud/resolver-inputs.ts
|
|
95
|
+
import {
|
|
96
|
+
clientTransportEnvKeys as clientTransportEnvKeys2,
|
|
97
|
+
credentialOverrideEnvKey,
|
|
98
|
+
credentialPointerEnvKey,
|
|
99
|
+
CREDENTIAL_PROFILE_ENV_KEY
|
|
100
|
+
} from "@hasna/contracts/client";
|
|
101
|
+
var CONTRACTS_AMBIENT_ENVIRONMENT = Symbol.for("hasna:contracts:ambientClientEnvironment");
|
|
102
|
+
function isAmbientContactsEnv(env) {
|
|
103
|
+
if (typeof process !== "undefined" && env === process.env)
|
|
104
|
+
return true;
|
|
105
|
+
return env[CONTRACTS_AMBIENT_ENVIRONMENT] === true;
|
|
106
|
+
}
|
|
107
|
+
function contactsResolverCredentials(env, credentials = {}) {
|
|
108
|
+
const keychain = { ...credentials.keychain };
|
|
109
|
+
if (keychain.enabled === undefined && keychain.run === undefined) {
|
|
110
|
+
keychain.enabled = isAmbientContactsEnv(env);
|
|
111
|
+
}
|
|
112
|
+
return { ...credentials, keychain };
|
|
113
|
+
}
|
|
114
|
+
|
|
93
115
|
// src/cloud/http-storage.ts
|
|
94
116
|
var RETIRED_CLIENT_SELECTOR_KEYS = [
|
|
95
117
|
"HASNA_CONTACTS_STORAGE_MODE",
|
|
@@ -125,37 +147,44 @@ class ContactsClientConfigurationError extends Error {
|
|
|
125
147
|
this.name = "ContactsClientConfigurationError";
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
|
-
function unconfiguredResolution(resolution,
|
|
150
|
+
function unconfiguredResolution(issue, resolution, warning = null) {
|
|
129
151
|
return {
|
|
130
152
|
transport: "unconfigured",
|
|
131
153
|
baseUrl: null,
|
|
132
|
-
apiUrlSource: resolution
|
|
133
|
-
apiKeyPresent: resolution
|
|
134
|
-
apiKeySource: resolution
|
|
135
|
-
apiKeyTier: resolution
|
|
154
|
+
apiUrlSource: resolution?.apiUrlSource ?? null,
|
|
155
|
+
apiKeyPresent: resolution?.apiKeyPresent ?? false,
|
|
156
|
+
apiKeySource: resolution?.apiKeySource ?? null,
|
|
157
|
+
apiKeyTier: resolution?.apiKeyTier ?? null,
|
|
136
158
|
configured: false,
|
|
137
159
|
misconfigured: true,
|
|
138
160
|
issue,
|
|
139
|
-
warning
|
|
161
|
+
warning
|
|
140
162
|
};
|
|
141
163
|
}
|
|
142
|
-
function resolveContactsClientTransport(name, env = process.env) {
|
|
164
|
+
function resolveContactsClientTransport(name, env = process.env, credentials = {}) {
|
|
143
165
|
if (name !== "contacts") {
|
|
144
166
|
throw new ContactsClientConfigurationError("CONTACTS_CLIENT_NAME_INVALID", "This resolver only accepts the contacts app slug.");
|
|
145
167
|
}
|
|
146
168
|
assertNoRetiredClientSelectors(env);
|
|
147
169
|
const stamp = clientConfigurationStamp(env);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
let resolution;
|
|
171
|
+
try {
|
|
172
|
+
resolution = resolveSharedClientTransport(name, env, {
|
|
173
|
+
credentials: contactsResolverCredentials(env, credentials)
|
|
174
|
+
});
|
|
175
|
+
} catch (error) {
|
|
176
|
+
assertConfigurationUnchanged(env, stamp);
|
|
177
|
+
if (error instanceof ClientTransportConfigurationError) {
|
|
178
|
+
return unconfiguredResolution(error.message, null);
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
153
181
|
}
|
|
182
|
+
assertConfigurationUnchanged(env, stamp);
|
|
154
183
|
try {
|
|
155
184
|
assertHttpsBaseUrl(resolution.baseUrl);
|
|
156
185
|
} catch (error) {
|
|
157
186
|
return {
|
|
158
|
-
...unconfiguredResolution(
|
|
187
|
+
...unconfiguredResolution(error instanceof Error ? error.message : String(error), resolution),
|
|
159
188
|
apiKeyPresent: resolution.apiKeyPresent
|
|
160
189
|
};
|
|
161
190
|
}
|
|
@@ -169,7 +198,7 @@ function resolveContactsClientTransport(name, env = process.env) {
|
|
|
169
198
|
configured: true,
|
|
170
199
|
misconfigured: false,
|
|
171
200
|
issue: null,
|
|
172
|
-
warning:
|
|
201
|
+
warning: resolution.warning
|
|
173
202
|
};
|
|
174
203
|
}
|
|
175
204
|
function resourcePath(resource) {
|
|
@@ -223,20 +252,21 @@ function createStorageClient(name, transport) {
|
|
|
223
252
|
}
|
|
224
253
|
};
|
|
225
254
|
}
|
|
226
|
-
function resolveContactsStorageClient(name, env = process.env) {
|
|
227
|
-
const resolution = resolveContactsClientTransport(name, env);
|
|
255
|
+
function resolveContactsStorageClient(name, env = process.env, credentials = {}) {
|
|
256
|
+
const resolution = resolveContactsClientTransport(name, env, credentials);
|
|
228
257
|
if (!resolution.configured || !resolution.baseUrl) {
|
|
229
258
|
throw new ContactsClientConfigurationError("CONTACTS_API_NOT_CONFIGURED", `${resolution.issue ?? "The contacts API client is not configured."} ` + "Configure HASNA_CONTACTS_API_URL and a contacts API key; the client will not read or create a local SQLite database.");
|
|
230
259
|
}
|
|
231
260
|
const baseUrl = resolution.baseUrl;
|
|
261
|
+
const chainOptions = contactsResolverCredentials(env, credentials);
|
|
232
262
|
const request = async (method, path, body, opts) => {
|
|
233
263
|
const stamp = clientConfigurationStamp(env);
|
|
234
264
|
const snapshot = { ...env };
|
|
235
|
-
const current = resolveContactsClientTransport(name, snapshot);
|
|
265
|
+
const current = resolveContactsClientTransport(name, snapshot, chainOptions);
|
|
236
266
|
if (!current.configured || current.baseUrl !== baseUrl) {
|
|
237
267
|
throw new ContactsClientConfigurationError("CONTACTS_AUTHORITY_CHANGED", "Client authority changed or disappeared; construct a new client before sending data.");
|
|
238
268
|
}
|
|
239
|
-
const credential = resolveCredential(name, snapshot);
|
|
269
|
+
const credential = resolveCredential(name, snapshot, chainOptions);
|
|
240
270
|
if (!credential)
|
|
241
271
|
throw new ContactsClientConfigurationError("CONTACTS_API_NOT_CONFIGURED", "No credential is available.");
|
|
242
272
|
assertConfigurationUnchanged(env, stamp);
|
|
@@ -979,6 +1009,9 @@ class InvalidAudienceDefinitionError extends Error {
|
|
|
979
1009
|
this.name = "InvalidAudienceDefinitionError";
|
|
980
1010
|
}
|
|
981
1011
|
}
|
|
1012
|
+
// src/sdk/index.ts
|
|
1013
|
+
import { resolveCredential as resolveCredential2 } from "@hasna/contracts/client";
|
|
1014
|
+
|
|
982
1015
|
// src/sdk/v1.generated.ts
|
|
983
1016
|
class ApiError extends Error {
|
|
984
1017
|
status;
|
|
@@ -1239,15 +1272,11 @@ function validateBaseUrl(raw) {
|
|
|
1239
1272
|
throw new Error("ContactsV1Client baseUrl must not contain credentials.");
|
|
1240
1273
|
if (url.search || url.hash)
|
|
1241
1274
|
throw new Error("ContactsV1Client baseUrl must not contain a query or fragment.");
|
|
1242
|
-
|
|
1243
|
-
if (path && path !== "/v1") {
|
|
1244
|
-
throw new Error("ContactsV1Client baseUrl must be an authority root or end in /v1.");
|
|
1245
|
-
}
|
|
1246
|
-
url.pathname = "";
|
|
1275
|
+
url.pathname = url.pathname.replace(/\/+$/, "").replace(/\/v1$/, "");
|
|
1247
1276
|
return url.toString().replace(/\/+$/, "");
|
|
1248
1277
|
}
|
|
1249
1278
|
function validateApiKey(apiKey) {
|
|
1250
|
-
const key = apiKey.trim();
|
|
1279
|
+
const key = (apiKey ?? "").trim();
|
|
1251
1280
|
if (!key)
|
|
1252
1281
|
throw new Error("ContactsV1Client requires an API key.");
|
|
1253
1282
|
if (/[^\t\x20-\x7e]/.test(key)) {
|
|
@@ -1267,6 +1296,56 @@ class ContactsV1Client2 extends ContactsV1Client {
|
|
|
1267
1296
|
});
|
|
1268
1297
|
}
|
|
1269
1298
|
}
|
|
1299
|
+
var CONTACTS_APP_NAME = "contacts";
|
|
1300
|
+
function contactsSdkAuthorityPinMessage() {
|
|
1301
|
+
return "an explicit baseUrl requires an explicit apiKey. The SDK never attaches a credential that " + "resolved for a different authority: pass `apiKey` explicitly, or omit `baseUrl` and let the " + "@hasna/contracts chain resolve both halves together.";
|
|
1302
|
+
}
|
|
1303
|
+
var SDK_HOSTED_ONLY = "The contacts SDK is hosted-only and never falls back to local data.";
|
|
1304
|
+
function resolveSdkCredential(env, chainOptions) {
|
|
1305
|
+
const credential = resolveCredential2(CONTACTS_APP_NAME, env, chainOptions);
|
|
1306
|
+
if (!credential) {
|
|
1307
|
+
const diagnosis = resolveContactsClientTransport(CONTACTS_APP_NAME, env, chainOptions);
|
|
1308
|
+
throw new ContactsClientConfigurationError("CONTACTS_API_NOT_CONFIGURED", `${diagnosis.issue ?? "No contacts credential resolved."} ${SDK_HOSTED_ONLY}`);
|
|
1309
|
+
}
|
|
1310
|
+
if (credential.tier === "pointer") {
|
|
1311
|
+
throw new ContactsClientConfigurationError("CONTACTS_CREDENTIAL_POINTER_UNSUPPORTED", `The contacts SDK resolves credentials synchronously and cannot complete the secrets-vault pointer ` + `${credential.source} per request. Use a literal tier instead: an explicit apiKey, the Keychain item ` + `hasna.credentials.${CONTACTS_APP_NAME}.api-key, ~/.hasna/${CONTACTS_APP_NAME}/config/credentials, ` + `or HASNA_CONTACTS_API_KEY.`);
|
|
1312
|
+
}
|
|
1313
|
+
return credential.apiKey;
|
|
1314
|
+
}
|
|
1315
|
+
function createContactsClient(options = {}) {
|
|
1316
|
+
const { baseUrl, apiKey, env, profile, keychain, ...clientOptions } = options;
|
|
1317
|
+
if (baseUrl !== undefined) {
|
|
1318
|
+
if (!apiKey)
|
|
1319
|
+
throw new ContactsClientConfigurationError("CONTACTS_CREDENTIAL_PINNED", contactsSdkAuthorityPinMessage());
|
|
1320
|
+
return new ContactsV1Client2({ ...clientOptions, baseUrl, apiKey });
|
|
1321
|
+
}
|
|
1322
|
+
const envObject = env ?? (typeof process !== "undefined" ? process.env : {});
|
|
1323
|
+
const requested = {
|
|
1324
|
+
...apiKey !== undefined ? { apiKey } : {},
|
|
1325
|
+
...profile !== undefined ? { profile } : {},
|
|
1326
|
+
...keychain !== undefined ? { keychain } : {}
|
|
1327
|
+
};
|
|
1328
|
+
const chainOptions = contactsResolverCredentials(envObject, requested);
|
|
1329
|
+
const initialKey = resolveSdkCredential(envObject, chainOptions);
|
|
1330
|
+
const resolution = resolveContactsClientTransport(CONTACTS_APP_NAME, envObject, { ...chainOptions, apiKey: initialKey });
|
|
1331
|
+
if (!resolution.configured || !resolution.baseUrl) {
|
|
1332
|
+
throw new ContactsClientConfigurationError("CONTACTS_API_NOT_CONFIGURED", `${resolution.issue ?? "The contacts API client is not configured."} ${SDK_HOSTED_ONLY}`);
|
|
1333
|
+
}
|
|
1334
|
+
const pinnedBaseUrl = resolution.baseUrl;
|
|
1335
|
+
const baseFetch = clientOptions.fetch ?? globalThis.fetch;
|
|
1336
|
+
const chainFetch = async (input, init) => {
|
|
1337
|
+
const snapshot = { ...envObject };
|
|
1338
|
+
const freshKey = resolveSdkCredential(snapshot, chainOptions);
|
|
1339
|
+
const current = resolveContactsClientTransport(CONTACTS_APP_NAME, snapshot, { ...chainOptions, apiKey: freshKey });
|
|
1340
|
+
if (!current.configured || current.baseUrl !== pinnedBaseUrl) {
|
|
1341
|
+
throw new ContactsClientConfigurationError("CONTACTS_AUTHORITY_CHANGED", "Client authority changed or disappeared; construct a new client before sending data.");
|
|
1342
|
+
}
|
|
1343
|
+
const headers = new Headers(init?.headers);
|
|
1344
|
+
headers.set("x-api-key", freshKey);
|
|
1345
|
+
return baseFetch(input, { ...init, headers });
|
|
1346
|
+
};
|
|
1347
|
+
return new ContactsV1Client2({ ...clientOptions, baseUrl: pinnedBaseUrl, apiKey: initialKey, fetch: chainFetch });
|
|
1348
|
+
}
|
|
1270
1349
|
// src/lib/package-version.ts
|
|
1271
1350
|
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
1272
1351
|
import { dirname, join } from "path";
|
|
@@ -1864,6 +1943,8 @@ function buildV1OpenApiDocument(version = getPackageVersion()) {
|
|
|
1864
1943
|
export {
|
|
1865
1944
|
resetStoreCache,
|
|
1866
1945
|
getStore,
|
|
1946
|
+
createContactsClient,
|
|
1947
|
+
contactsSdkAuthorityPinMessage,
|
|
1867
1948
|
buildV1OpenApiDocument,
|
|
1868
1949
|
TagNotFoundError,
|
|
1869
1950
|
InvalidAudienceDefinitionError,
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
export declare function buildServer(): McpServer;
|
|
4
|
+
/**
|
|
5
|
+
* Classify early-exit arguments before any http-mode parse, server build, or
|
|
6
|
+
* stdio bind. `--help` / `--version` answer with rc=0 and the MCP server never
|
|
7
|
+
* starts: previously `contacts-mcp --version` fell through to the stdio
|
|
8
|
+
* JSON-RPC loop and printed "running on stdio" instead of the version
|
|
9
|
+
* (hasna/apps#1720 validation, the binds-before-version class).
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleEarlyArgs(argv: string[]): "help" | "version" | "start";
|
|
12
|
+
export declare function mcpUsage(): string;
|
|
4
13
|
export declare function isDirectMcpEntry(entry?: string): boolean;
|
|
5
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiBpE,wBAAgB,WAAW,IAAI,SAAS,CAKvC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAI5E;AAED,wBAAgB,QAAQ,IAAI,MAAM,CASjC;AA0CD,wBAAgB,gBAAgB,CAAC,KAAK,SAAkB,GAAG,OAAO,CAIjE"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -19811,6 +19811,7 @@ function readConnectorTokens(name, profile = "default") {
|
|
|
19811
19811
|
|
|
19812
19812
|
// src/cloud/http-storage.ts
|
|
19813
19813
|
import {
|
|
19814
|
+
ClientTransportConfigurationError,
|
|
19814
19815
|
createHasnaHttpTransport,
|
|
19815
19816
|
resolveCredential,
|
|
19816
19817
|
resolveClientTransport as resolveSharedClientTransport
|
|
@@ -19900,6 +19901,27 @@ function assertConfigurationUnchanged(env, expected) {
|
|
|
19900
19901
|
invalid();
|
|
19901
19902
|
}
|
|
19902
19903
|
|
|
19904
|
+
// src/cloud/resolver-inputs.ts
|
|
19905
|
+
import {
|
|
19906
|
+
clientTransportEnvKeys as clientTransportEnvKeys2,
|
|
19907
|
+
credentialOverrideEnvKey,
|
|
19908
|
+
credentialPointerEnvKey,
|
|
19909
|
+
CREDENTIAL_PROFILE_ENV_KEY
|
|
19910
|
+
} from "@hasna/contracts/client";
|
|
19911
|
+
var CONTRACTS_AMBIENT_ENVIRONMENT = Symbol.for("hasna:contracts:ambientClientEnvironment");
|
|
19912
|
+
function isAmbientContactsEnv(env) {
|
|
19913
|
+
if (typeof process !== "undefined" && env === process.env)
|
|
19914
|
+
return true;
|
|
19915
|
+
return env[CONTRACTS_AMBIENT_ENVIRONMENT] === true;
|
|
19916
|
+
}
|
|
19917
|
+
function contactsResolverCredentials(env, credentials = {}) {
|
|
19918
|
+
const keychain = { ...credentials.keychain };
|
|
19919
|
+
if (keychain.enabled === undefined && keychain.run === undefined) {
|
|
19920
|
+
keychain.enabled = isAmbientContactsEnv(env);
|
|
19921
|
+
}
|
|
19922
|
+
return { ...credentials, keychain };
|
|
19923
|
+
}
|
|
19924
|
+
|
|
19903
19925
|
// src/cloud/http-storage.ts
|
|
19904
19926
|
var RETIRED_CLIENT_SELECTOR_KEYS = [
|
|
19905
19927
|
"HASNA_CONTACTS_STORAGE_MODE",
|
|
@@ -19935,37 +19957,44 @@ class ContactsClientConfigurationError extends Error {
|
|
|
19935
19957
|
this.name = "ContactsClientConfigurationError";
|
|
19936
19958
|
}
|
|
19937
19959
|
}
|
|
19938
|
-
function unconfiguredResolution(resolution,
|
|
19960
|
+
function unconfiguredResolution(issue2, resolution, warning = null) {
|
|
19939
19961
|
return {
|
|
19940
19962
|
transport: "unconfigured",
|
|
19941
19963
|
baseUrl: null,
|
|
19942
|
-
apiUrlSource: resolution
|
|
19943
|
-
apiKeyPresent: resolution
|
|
19944
|
-
apiKeySource: resolution
|
|
19945
|
-
apiKeyTier: resolution
|
|
19964
|
+
apiUrlSource: resolution?.apiUrlSource ?? null,
|
|
19965
|
+
apiKeyPresent: resolution?.apiKeyPresent ?? false,
|
|
19966
|
+
apiKeySource: resolution?.apiKeySource ?? null,
|
|
19967
|
+
apiKeyTier: resolution?.apiKeyTier ?? null,
|
|
19946
19968
|
configured: false,
|
|
19947
19969
|
misconfigured: true,
|
|
19948
19970
|
issue: issue2,
|
|
19949
|
-
warning
|
|
19971
|
+
warning
|
|
19950
19972
|
};
|
|
19951
19973
|
}
|
|
19952
|
-
function resolveContactsClientTransport(name, env = process.env) {
|
|
19974
|
+
function resolveContactsClientTransport(name, env = process.env, credentials = {}) {
|
|
19953
19975
|
if (name !== "contacts") {
|
|
19954
19976
|
throw new ContactsClientConfigurationError("CONTACTS_CLIENT_NAME_INVALID", "This resolver only accepts the contacts app slug.");
|
|
19955
19977
|
}
|
|
19956
19978
|
assertNoRetiredClientSelectors(env);
|
|
19957
19979
|
const stamp = clientConfigurationStamp(env);
|
|
19958
|
-
|
|
19959
|
-
|
|
19960
|
-
|
|
19961
|
-
|
|
19962
|
-
|
|
19980
|
+
let resolution;
|
|
19981
|
+
try {
|
|
19982
|
+
resolution = resolveSharedClientTransport(name, env, {
|
|
19983
|
+
credentials: contactsResolverCredentials(env, credentials)
|
|
19984
|
+
});
|
|
19985
|
+
} catch (error2) {
|
|
19986
|
+
assertConfigurationUnchanged(env, stamp);
|
|
19987
|
+
if (error2 instanceof ClientTransportConfigurationError) {
|
|
19988
|
+
return unconfiguredResolution(error2.message, null);
|
|
19989
|
+
}
|
|
19990
|
+
throw error2;
|
|
19963
19991
|
}
|
|
19992
|
+
assertConfigurationUnchanged(env, stamp);
|
|
19964
19993
|
try {
|
|
19965
19994
|
assertHttpsBaseUrl(resolution.baseUrl);
|
|
19966
19995
|
} catch (error2) {
|
|
19967
19996
|
return {
|
|
19968
|
-
...unconfiguredResolution(
|
|
19997
|
+
...unconfiguredResolution(error2 instanceof Error ? error2.message : String(error2), resolution),
|
|
19969
19998
|
apiKeyPresent: resolution.apiKeyPresent
|
|
19970
19999
|
};
|
|
19971
20000
|
}
|
|
@@ -19979,7 +20008,7 @@ function resolveContactsClientTransport(name, env = process.env) {
|
|
|
19979
20008
|
configured: true,
|
|
19980
20009
|
misconfigured: false,
|
|
19981
20010
|
issue: null,
|
|
19982
|
-
warning:
|
|
20011
|
+
warning: resolution.warning
|
|
19983
20012
|
};
|
|
19984
20013
|
}
|
|
19985
20014
|
function resourcePath(resource) {
|
|
@@ -20033,20 +20062,21 @@ function createStorageClient(name, transport) {
|
|
|
20033
20062
|
}
|
|
20034
20063
|
};
|
|
20035
20064
|
}
|
|
20036
|
-
function resolveContactsStorageClient(name, env = process.env) {
|
|
20037
|
-
const resolution = resolveContactsClientTransport(name, env);
|
|
20065
|
+
function resolveContactsStorageClient(name, env = process.env, credentials = {}) {
|
|
20066
|
+
const resolution = resolveContactsClientTransport(name, env, credentials);
|
|
20038
20067
|
if (!resolution.configured || !resolution.baseUrl) {
|
|
20039
20068
|
throw new ContactsClientConfigurationError("CONTACTS_API_NOT_CONFIGURED", `${resolution.issue ?? "The contacts API client is not configured."} ` + "Configure HASNA_CONTACTS_API_URL and a contacts API key; the client will not read or create a local SQLite database.");
|
|
20040
20069
|
}
|
|
20041
20070
|
const baseUrl = resolution.baseUrl;
|
|
20071
|
+
const chainOptions = contactsResolverCredentials(env, credentials);
|
|
20042
20072
|
const request = async (method, path, body, opts) => {
|
|
20043
20073
|
const stamp = clientConfigurationStamp(env);
|
|
20044
20074
|
const snapshot = { ...env };
|
|
20045
|
-
const current = resolveContactsClientTransport(name, snapshot);
|
|
20075
|
+
const current = resolveContactsClientTransport(name, snapshot, chainOptions);
|
|
20046
20076
|
if (!current.configured || current.baseUrl !== baseUrl) {
|
|
20047
20077
|
throw new ContactsClientConfigurationError("CONTACTS_AUTHORITY_CHANGED", "Client authority changed or disappeared; construct a new client before sending data.");
|
|
20048
20078
|
}
|
|
20049
|
-
const credential = resolveCredential(name, snapshot);
|
|
20079
|
+
const credential = resolveCredential(name, snapshot, chainOptions);
|
|
20050
20080
|
if (!credential)
|
|
20051
20081
|
throw new ContactsClientConfigurationError("CONTACTS_API_NOT_CONFIGURED", "No credential is available.");
|
|
20052
20082
|
assertConfigurationUnchanged(env, stamp);
|
|
@@ -24678,6 +24708,37 @@ function registerContactsStorageTools(server) {
|
|
|
24678
24708
|
});
|
|
24679
24709
|
}
|
|
24680
24710
|
|
|
24711
|
+
// src/mcp/startup-gate.ts
|
|
24712
|
+
import {
|
|
24713
|
+
completePointerCredential,
|
|
24714
|
+
resolveCredential as resolveCredential2
|
|
24715
|
+
} from "@hasna/contracts/client";
|
|
24716
|
+
var MCP_REFUSAL_PREFIX = "contacts-mcp: refusing to start \u2014";
|
|
24717
|
+
var MCP_REFUSAL_HINT = "The MCP server never serves tools without a contacts credential and never reads or creates a local store; " + "configure the credential and restart contacts-mcp.";
|
|
24718
|
+
async function resolveMcpStartupGate(env = process.env, credentials = {}, options = {}) {
|
|
24719
|
+
let issue2;
|
|
24720
|
+
try {
|
|
24721
|
+
const resolution = resolveContactsClientTransport("contacts", env, credentials);
|
|
24722
|
+
if (resolution.configured) {
|
|
24723
|
+
if (resolution.apiKeyTier !== "pointer") {
|
|
24724
|
+
return { ok: true, apiUrlSource: resolution.apiUrlSource, apiKeySource: resolution.apiKeySource };
|
|
24725
|
+
}
|
|
24726
|
+
const chainOptions = contactsResolverCredentials(env, credentials);
|
|
24727
|
+
const pointer = resolveCredential2("contacts", env, chainOptions);
|
|
24728
|
+
if (!pointer || pointer.tier !== "pointer") {
|
|
24729
|
+
throw new Error(`${resolution.apiKeySource ?? "HASNA_CONTACTS_API_KEY_REF"} resolved as a vault pointer but produced no pointer credential; this is a defect in the resolver.`);
|
|
24730
|
+
}
|
|
24731
|
+
const completed = await (options.completePointer ?? completePointerCredential)("contacts", pointer, env);
|
|
24732
|
+
return { ok: true, apiUrlSource: resolution.apiUrlSource, apiKeySource: completed.source };
|
|
24733
|
+
}
|
|
24734
|
+
issue2 = `CONTACTS_API_NOT_CONFIGURED: ${resolution.issue ?? "The contacts API client is not configured."}`;
|
|
24735
|
+
} catch (error2) {
|
|
24736
|
+
issue2 = error2 instanceof Error ? error2.message : String(error2);
|
|
24737
|
+
}
|
|
24738
|
+
return { ok: false, message: `${MCP_REFUSAL_PREFIX} ${issue2}
|
|
24739
|
+
${MCP_REFUSAL_HINT}` };
|
|
24740
|
+
}
|
|
24741
|
+
|
|
24681
24742
|
// ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0+2b91fc17bf64bdfd/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
24682
24743
|
var import_content_type = __toESM(require_content_type(), 1);
|
|
24683
24744
|
function mediaTypeEssence(header) {
|
|
@@ -25434,8 +25495,39 @@ function buildServer() {
|
|
|
25434
25495
|
registerContactsStorageTools(server);
|
|
25435
25496
|
return server;
|
|
25436
25497
|
}
|
|
25498
|
+
function handleEarlyArgs(argv) {
|
|
25499
|
+
if (argv.includes("--help") || argv.includes("-h"))
|
|
25500
|
+
return "help";
|
|
25501
|
+
if (argv.includes("--version") || argv.includes("-V"))
|
|
25502
|
+
return "version";
|
|
25503
|
+
return "start";
|
|
25504
|
+
}
|
|
25505
|
+
function mcpUsage() {
|
|
25506
|
+
return `usage: contacts-mcp MCP server over stdio (default)
|
|
25507
|
+
contacts-mcp --http [--port <n>] Streamable-HTTP dev server (loopback)
|
|
25508
|
+
contacts-mcp --version Print the version
|
|
25509
|
+
|
|
25510
|
+
options:
|
|
25511
|
+
--help, -h show this help and exit
|
|
25512
|
+
--version, -V print the package version and exit
|
|
25513
|
+
`;
|
|
25514
|
+
}
|
|
25437
25515
|
async function main() {
|
|
25438
25516
|
const args = process.argv.slice(2);
|
|
25517
|
+
const early = handleEarlyArgs(args);
|
|
25518
|
+
if (early === "help") {
|
|
25519
|
+
console.log(mcpUsage());
|
|
25520
|
+
return;
|
|
25521
|
+
}
|
|
25522
|
+
if (early === "version") {
|
|
25523
|
+
console.log(getServerVersion());
|
|
25524
|
+
return;
|
|
25525
|
+
}
|
|
25526
|
+
const gate = await resolveMcpStartupGate();
|
|
25527
|
+
if (!gate.ok) {
|
|
25528
|
+
console.error(gate.message);
|
|
25529
|
+
process.exit(1);
|
|
25530
|
+
}
|
|
25439
25531
|
if (isHttpMode(args)) {
|
|
25440
25532
|
startMcpHttpServer({
|
|
25441
25533
|
name: "contacts",
|
|
@@ -25461,6 +25553,8 @@ if (isDirectMcpEntry()) {
|
|
|
25461
25553
|
});
|
|
25462
25554
|
}
|
|
25463
25555
|
export {
|
|
25556
|
+
mcpUsage,
|
|
25464
25557
|
isDirectMcpEntry,
|
|
25558
|
+
handleEarlyArgs,
|
|
25465
25559
|
buildServer
|
|
25466
25560
|
};
|