gtmmaxing 0.1.1 → 0.1.3
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 +3 -0
- package/dist/gtm.js +295 -45
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -25,6 +25,9 @@ gtm contacts satyanadella --verify --dry-run
|
|
|
25
25
|
gtm contacts --file leads.csv --verify --out enriched.csv --max-credits 50
|
|
26
26
|
gtm list --titles 'VP Sales' --location 'United States' --max-credits 20
|
|
27
27
|
gtm research acme.com --max-credits 5
|
|
28
|
+
gtm tools describe seo-aeo-audit
|
|
29
|
+
gtm tools run seo-aeo-audit --input '{"url":"example.com"}' --dry-run
|
|
30
|
+
gtm tools run seo-aeo-audit --input '{"url":"example.com"}' --max-credits 35
|
|
28
31
|
gtm results <run_id> --csv > out.csv
|
|
29
32
|
```
|
|
30
33
|
|
package/dist/gtm.js
CHANGED
|
@@ -10426,8 +10426,8 @@ var error43 = () => {
|
|
|
10426
10426
|
case "not_multiple_of":
|
|
10427
10427
|
return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
|
|
10428
10428
|
case "unrecognized_keys": {
|
|
10429
|
-
const
|
|
10430
|
-
return `Chave${
|
|
10429
|
+
const plural3 = issue2.keys.length > 1 ? "s" : "";
|
|
10430
|
+
return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
|
|
10431
10431
|
}
|
|
10432
10432
|
case "invalid_key":
|
|
10433
10433
|
return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
|
|
@@ -10569,8 +10569,8 @@ var error44 = () => {
|
|
|
10569
10569
|
case "not_multiple_of":
|
|
10570
10570
|
return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
|
|
10571
10571
|
case "unrecognized_keys": {
|
|
10572
|
-
const
|
|
10573
|
-
return `Chave${
|
|
10572
|
+
const plural3 = issue2.keys.length > 1 ? "s" : "";
|
|
10573
|
+
return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
|
|
10574
10574
|
}
|
|
10575
10575
|
case "invalid_key":
|
|
10576
10576
|
return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
|
|
@@ -18873,6 +18873,7 @@ function date4(params) {
|
|
|
18873
18873
|
|
|
18874
18874
|
// ../contracts/src/tools.ts
|
|
18875
18875
|
var TOOL_CATALOG = {
|
|
18876
|
+
"seo-aeo-audit": { name: "SEO/AEO audit", credits: 35, unit: "completed audit", limit: 1 },
|
|
18876
18877
|
company: { name: "Company enrichment", credits: 1, unit: "company", limit: 1 },
|
|
18877
18878
|
"local-leads": { name: "Local business leads", credits: 1, unit: "search (up to 20 businesses)", limit: 20 },
|
|
18878
18879
|
website: { name: "Website brief", credits: 1, unit: "brief", limit: 1 },
|
|
@@ -18883,6 +18884,8 @@ var TOOL_CATALOG = {
|
|
|
18883
18884
|
"people-search": { name: "People search", credits: 2, unit: "search (up to 20 people)", limit: 20 },
|
|
18884
18885
|
"google-search": { name: "Google search", credits: 1, unit: "search (up to 20 results)", limit: 20 },
|
|
18885
18886
|
"linkedin-profile": { name: "LinkedIn profile", credits: 1, unit: "profile", limit: 1 },
|
|
18887
|
+
"linkedin-activity": { name: "LinkedIn activity", credits: 1, unit: "profile with posts", limit: 1 },
|
|
18888
|
+
"profile-finder": { name: "Find LinkedIn profile", credits: 1, unit: "profile found", limit: 1 },
|
|
18886
18889
|
"page-content": { name: "Web page content", credits: 1, unit: "page", limit: 1 }
|
|
18887
18890
|
};
|
|
18888
18891
|
var toolIdSchema = external_exports.enum(Object.keys(TOOL_CATALOG));
|
|
@@ -18905,15 +18908,18 @@ var toolRequestSchema = external_exports.object({
|
|
|
18905
18908
|
company: external_exports.string().trim().max(100).default(""),
|
|
18906
18909
|
location: external_exports.string().trim().max(100).default(""),
|
|
18907
18910
|
titles: external_exports.string().trim().max(200).default(""),
|
|
18911
|
+
/** LinkedIn activity: comma-separated topics to look for in posts. Optional so older saved requests keep their hash. */
|
|
18912
|
+
keywords: external_exports.string().trim().max(300).optional(),
|
|
18908
18913
|
limit: external_exports.number().int().min(1).max(20).default(10)
|
|
18909
18914
|
}).strict().superRefine((v, c) => {
|
|
18910
18915
|
const reject = (message) => c.addIssue({ code: "custom", path: ["query"], message });
|
|
18911
18916
|
if (v.careerBoard && !/^https:\/\/(boards\.greenhouse\.io|jobs\.lever\.co)\/[a-zA-Z0-9_-]+\/?$/.test(v.careerBoard)) reject("Use a public Greenhouse or Lever company board URL.");
|
|
18912
|
-
if (["website", "page-content"].includes(v.tool) && !publicWebsite(websiteUrl(v.query))) reject("Enter a company website, like vercel.com.");
|
|
18917
|
+
if (["website", "page-content", "seo-aeo-audit"].includes(v.tool) && !publicWebsite(websiteUrl(v.query))) reject("Enter a company website, like vercel.com.");
|
|
18913
18918
|
if (["company", "icp"].includes(v.tool) && !publicWebsite(`https://${v.query.replace(/^https?:\/\//, "").replace(/\/$/, "")}`)) reject("Enter a public company domain.");
|
|
18914
18919
|
if (v.tool === "local-leads" && !v.location) reject("Add a city or region.");
|
|
18920
|
+
if (v.tool === "profile-finder" && !v.company) c.addIssue({ code: "custom", path: ["company"], message: "Add the person's company." });
|
|
18915
18921
|
if (v.tool === "verify-email" && !external_exports.string().email().safeParse(v.query).success) reject("Enter an email address.");
|
|
18916
|
-
if (["phone-pilot", "linkedin-profile"].includes(v.tool) && !/^https:\/\/(www\.)?linkedin\.com\/in\/[a-zA-Z0-9%_-]+\/?$/.test(v.query)) reject("Enter a LinkedIn profile URL.");
|
|
18922
|
+
if (["phone-pilot", "linkedin-profile", "linkedin-activity"].includes(v.tool) && !/^https:\/\/(www\.)?linkedin\.com\/in\/[a-zA-Z0-9%_-]+\/?$/.test(v.query)) reject("Enter a LinkedIn profile URL.");
|
|
18917
18923
|
});
|
|
18918
18924
|
var toolResultSchema = external_exports.object({
|
|
18919
18925
|
rows: external_exports.array(external_exports.record(external_exports.string(), external_exports.union([external_exports.string().max(1e5), external_exports.number(), external_exports.boolean(), external_exports.null()]))).max(20),
|
|
@@ -18939,22 +18945,38 @@ var optionalText = (max) => external_exports.string().trim().max(max).optional()
|
|
|
18939
18945
|
var limit = (id) => external_exports.number().int().min(1).max(TOOL_CATALOG[id].limit).optional();
|
|
18940
18946
|
var s = external_exports.string();
|
|
18941
18947
|
var n = external_exports.number().nullable();
|
|
18948
|
+
var MAX_BATCH_PEOPLE = 100;
|
|
18949
|
+
var batchPeople = external_exports.array(text(300)).min(1).max(MAX_BATCH_PEOPLE).optional().describe(`Up to ${MAX_BATCH_PEOPLE} LinkedIn profile URLs or handles, instead of profile`);
|
|
18942
18950
|
var toolPrice = (id, free = "Empty results are free.") => ({
|
|
18943
18951
|
credits: TOOL_CATALOG[id].credits,
|
|
18944
18952
|
unit: TOOL_CATALOG[id].unit,
|
|
18945
18953
|
basis: "run",
|
|
18946
18954
|
free
|
|
18947
18955
|
});
|
|
18956
|
+
function canonicalProfileSlug(slug) {
|
|
18957
|
+
return /^AC[ow]AA/.test(slug) ? slug : slug.toLowerCase();
|
|
18958
|
+
}
|
|
18948
18959
|
function linkedinProfileUrl(value) {
|
|
18949
18960
|
const trimmed = value.trim();
|
|
18950
|
-
if (/^[A-Za-z0-9][A-Za-z0-9_%-]{0,99}$/.test(trimmed)) return `https://www.linkedin.com/in/${trimmed
|
|
18961
|
+
if (/^[A-Za-z0-9][A-Za-z0-9_%-]{0,99}$/.test(trimmed)) return `https://www.linkedin.com/in/${canonicalProfileSlug(trimmed)}`;
|
|
18951
18962
|
const match = /^(?:https?:\/\/)?(?:www\.)?linkedin\.com\/in\/([A-Za-z0-9_%-]{1,100})\/?(?:[?#].*)?$/i.exec(trimmed);
|
|
18952
|
-
return match ? `https://www.linkedin.com/in/${match[1]
|
|
18963
|
+
return match ? `https://www.linkedin.com/in/${canonicalProfileSlug(match[1])}` : trimmed;
|
|
18953
18964
|
}
|
|
18954
18965
|
function capability(definition) {
|
|
18955
18966
|
return definition;
|
|
18956
18967
|
}
|
|
18957
18968
|
var CAPABILITIES = {
|
|
18969
|
+
"seo-aeo-audit": capability({
|
|
18970
|
+
title: "SEO/AEO audit",
|
|
18971
|
+
description: "RankAI website audit for search engine and answer engine optimization, with a report URL when complete.",
|
|
18972
|
+
input: external_exports.object({ url: text(300) }).strict(),
|
|
18973
|
+
row: external_exports.object({ url: s, auditId: s, status: s, reportUrl: s }),
|
|
18974
|
+
preview: ["url", "status", "reportUrl"],
|
|
18975
|
+
noun: "audits",
|
|
18976
|
+
price: toolPrice("seo-aeo-audit", "Failed audits and empty results are free."),
|
|
18977
|
+
example: { url: "example.com" },
|
|
18978
|
+
toolRequest: (input2) => ({ tool: "seo-aeo-audit", query: input2.url })
|
|
18979
|
+
}),
|
|
18958
18980
|
"email-finder": capability({
|
|
18959
18981
|
title: "Email finder",
|
|
18960
18982
|
description: "Work email for each LinkedIn profile, checked before it is returned.",
|
|
@@ -18963,6 +18985,7 @@ var CAPABILITIES = {
|
|
|
18963
18985
|
preview: ["name", "email", "verdict"],
|
|
18964
18986
|
noun: "contacts",
|
|
18965
18987
|
price: { credits: 1, unit: "email found", basis: "result", free: "Misses and profiles you already paid for are free." },
|
|
18988
|
+
searchWords: "emails bulk batch list csv contact contacts enrich enrichment",
|
|
18966
18989
|
example: { people: ["https://www.linkedin.com/in/satyanadella"] }
|
|
18967
18990
|
}),
|
|
18968
18991
|
company: capability({
|
|
@@ -19066,14 +19089,47 @@ var CAPABILITIES = {
|
|
|
19066
19089
|
}),
|
|
19067
19090
|
"linkedin-profile": capability({
|
|
19068
19091
|
title: "LinkedIn profile",
|
|
19069
|
-
description: "Public LinkedIn profile: headline, role, company, location and about.",
|
|
19070
|
-
input: external_exports.object({ profile: text(300) }).strict(),
|
|
19092
|
+
description: "Public LinkedIn profile: headline, current role, company, location and about. One profile or up to 100 people.",
|
|
19093
|
+
input: external_exports.object({ profile: text(300).optional(), people: batchPeople }).strict(),
|
|
19071
19094
|
row: external_exports.object({ name: s, headline: s, role: s, company: s, location: s, followers: n, about: s, companyPage: s, url: s }),
|
|
19072
|
-
preview: ["name", "
|
|
19095
|
+
preview: ["name", "role", "company", "location"],
|
|
19073
19096
|
noun: "profiles",
|
|
19074
|
-
price: toolPrice("linkedin-profile"),
|
|
19097
|
+
price: toolPrice("linkedin-profile", "Profiles not found are free."),
|
|
19098
|
+
searchWords: "current job title employer moved changed change changes verify bulk batch list",
|
|
19075
19099
|
example: { profile: "https://www.linkedin.com/in/williamhgates" },
|
|
19076
|
-
toolRequest: (input2) => ({ tool: "linkedin-profile", query: linkedinProfileUrl(input2.profile) })
|
|
19100
|
+
toolRequest: (input2) => ({ tool: "linkedin-profile", query: linkedinProfileUrl(input2.profile ?? "") }),
|
|
19101
|
+
batch: true
|
|
19102
|
+
}),
|
|
19103
|
+
"linkedin-activity": capability({
|
|
19104
|
+
title: "LinkedIn activity",
|
|
19105
|
+
description: "Recent public LinkedIn posts with exact dates: last post, posts in 90 and 365 days, and posts on topics you name. One profile or up to 100 people.",
|
|
19106
|
+
input: external_exports.object({ profile: text(300).optional(), people: batchPeople, topics: external_exports.array(text(40)).max(10).optional().describe("Words to look for in the past year's posts, like automation") }).strict(),
|
|
19107
|
+
row: external_exports.object({ name: s, headline: s, lastPostAt: s, posts90d: external_exports.number(), posts365d: external_exports.number(), topics: s, topicPosts: n, post: s, postAt: s, postKind: s, postUrl: s, url: s }),
|
|
19108
|
+
preview: ["name", "lastPostAt", "posts90d", "topicPosts"],
|
|
19109
|
+
noun: "profiles",
|
|
19110
|
+
price: toolPrice("linkedin-activity", "Profiles with no public posts are free."),
|
|
19111
|
+
searchWords: "posting active activity talk talks talking mentions mentioned engagement social signal signals intent bulk batch list",
|
|
19112
|
+
example: { profile: "https://www.linkedin.com/in/williamhgates", topics: ["climate"] },
|
|
19113
|
+
// Commas would split a topic, so each is kept whole by dropping them.
|
|
19114
|
+
toolRequest: (input2) => ({ tool: "linkedin-activity", query: linkedinProfileUrl(input2.profile ?? ""), ...input2.topics?.length ? { keywords: input2.topics.map((t) => t.replace(/,/g, " ").trim()).join(", ") } : {} }),
|
|
19115
|
+
batch: true
|
|
19116
|
+
}),
|
|
19117
|
+
"profile-finder": capability({
|
|
19118
|
+
title: "Find LinkedIn profile",
|
|
19119
|
+
description: "A person's LinkedIn profile from their name and company, checked against both. One person or up to 100 people.",
|
|
19120
|
+
input: external_exports.object({
|
|
19121
|
+
name: text(100).optional().describe("Full name, like Pedro Reis"),
|
|
19122
|
+
company: text(100).optional().describe("Company name or domain, like Adyen"),
|
|
19123
|
+
people: external_exports.array(external_exports.object({ name: text(100), company: text(100) }).strict()).min(1).max(MAX_BATCH_PEOPLE).optional().describe(`Up to ${MAX_BATCH_PEOPLE} {name, company} pairs, instead of name and company`)
|
|
19124
|
+
}).strict(),
|
|
19125
|
+
row: external_exports.object({ name: s, title: s, company: s, location: s, url: s }),
|
|
19126
|
+
preview: ["name", "title", "company", "url"],
|
|
19127
|
+
noun: "profiles",
|
|
19128
|
+
price: toolPrice("profile-finder", "People not found are free."),
|
|
19129
|
+
example: { name: "Pedro Reis", company: "Adyen" },
|
|
19130
|
+
toolRequest: (input2) => ({ tool: "profile-finder", query: input2.name ?? "", company: input2.company ?? "" }),
|
|
19131
|
+
batch: true,
|
|
19132
|
+
searchWords: "linkedin url name names person lookup resolve match who bulk batch list"
|
|
19077
19133
|
}),
|
|
19078
19134
|
"page-content": capability({
|
|
19079
19135
|
title: "Web page content",
|
|
@@ -19091,13 +19147,15 @@ var CAPABILITY_IDS = Object.keys(CAPABILITIES);
|
|
|
19091
19147
|
var capabilityIdSchema = external_exports.enum(CAPABILITY_IDS);
|
|
19092
19148
|
var paidArgs = {
|
|
19093
19149
|
max_credits: external_exports.number().int().min(0).max(1e5).optional().describe("Most credits this call may spend"),
|
|
19094
|
-
|
|
19150
|
+
// Piped so the published input schema stays a plain string: every agent tool list has a 2k-token budget.
|
|
19151
|
+
idempotency_key: external_exports.string().pipe(external_exports.string().regex(/^[\x21-\x7e]{8,128}$/)).optional().describe("Same key replays the call for free"),
|
|
19095
19152
|
dry_run: external_exports.boolean().optional().describe("Quote only; nothing runs")
|
|
19096
19153
|
};
|
|
19097
19154
|
var price = (id) => TOOL_CATALOG[id].credits;
|
|
19098
19155
|
var findContactsInput = external_exports.object({
|
|
19099
19156
|
people: external_exports.array(text(300)).min(1).max(100).optional().describe("LinkedIn profile URLs or handles"),
|
|
19100
19157
|
run_id: external_exports.string().max(64).optional().describe("Use the people from a gtm_build_list run"),
|
|
19158
|
+
named: external_exports.array(external_exports.object({ name: external_exports.string().pipe(text(100)), company: external_exports.string().pipe(text(100)) }).strict()).min(1).max(100).optional().describe("{name, company} pairs, instead of people"),
|
|
19101
19159
|
find: external_exports.array(external_exports.enum(["email", "phone"])).min(1).max(2).optional().describe('Default ["email"]'),
|
|
19102
19160
|
verify: external_exports.boolean().optional().describe("Mailbox-check found emails"),
|
|
19103
19161
|
...paidArgs
|
|
@@ -19131,12 +19189,12 @@ var toolsInput = external_exports.object({
|
|
|
19131
19189
|
...paidArgs
|
|
19132
19190
|
}).strict();
|
|
19133
19191
|
var accountInput = external_exports.object({
|
|
19134
|
-
quote: external_exports.object({ capability: capabilityIdSchema, count: external_exports.number().int().min(1).max(1e5) }).strict().optional().describe("Price a planned batch")
|
|
19192
|
+
quote: external_exports.object({ capability: external_exports.string().pipe(capabilityIdSchema).describe("A gtm_tools capability"), count: external_exports.number().int().min(1).max(1e5) }).strict().optional().describe("Price a planned batch")
|
|
19135
19193
|
}).strict();
|
|
19136
19194
|
var OUTCOME_TOOLS = {
|
|
19137
19195
|
gtm_find_contacts: {
|
|
19138
19196
|
title: "Find contacts",
|
|
19139
|
-
description: `Work emails or mobiles for people, by LinkedIn profile or a gtm_build_list run_id. ${CAPABILITIES["email-finder"].price.credits} credit per email found, ${price("phone-pilot")} per phone, ${price("verify-email")} per verified email; misses free.`,
|
|
19197
|
+
description: `Work emails or mobiles for people, by LinkedIn profile, name and company, or a gtm_build_list run_id. ${CAPABILITIES["email-finder"].price.credits} credit per email found, ${price("phone-pilot")} per phone, ${price("verify-email")} per verified email; misses free.`,
|
|
19140
19198
|
paid: true,
|
|
19141
19199
|
capabilities: ["email-finder", "phone-pilot", "verify-email"],
|
|
19142
19200
|
input: findContactsInput
|
|
@@ -19150,7 +19208,7 @@ var OUTCOME_TOOLS = {
|
|
|
19150
19208
|
},
|
|
19151
19209
|
gtm_research_company: {
|
|
19152
19210
|
title: "Research a company",
|
|
19153
|
-
description: `Company profile and website sales brief for one domain
|
|
19211
|
+
description: `Company profile and website sales brief for one domain. Up to ${price("company") + price("website")} credits; misses free.`,
|
|
19154
19212
|
paid: true,
|
|
19155
19213
|
capabilities: ["company", "website"],
|
|
19156
19214
|
input: researchCompanyInput
|
|
@@ -19164,21 +19222,21 @@ var OUTCOME_TOOLS = {
|
|
|
19164
19222
|
},
|
|
19165
19223
|
gtm_results: {
|
|
19166
19224
|
title: "Get results",
|
|
19167
|
-
description: "Free
|
|
19225
|
+
description: "Free: run rows, job status or CSV link.",
|
|
19168
19226
|
paid: false,
|
|
19169
19227
|
capabilities: [],
|
|
19170
19228
|
input: resultsInput
|
|
19171
19229
|
},
|
|
19172
19230
|
gtm_tools: {
|
|
19173
19231
|
title: "Other tools",
|
|
19174
|
-
description: "Search, describe or run any catalog capability, like
|
|
19232
|
+
description: "Search, describe or run any catalog capability, like LinkedIn activity or SEO/AEO audits. Runs need max_credits.",
|
|
19175
19233
|
paid: true,
|
|
19176
19234
|
capabilities: CAPABILITY_IDS,
|
|
19177
19235
|
input: toolsInput
|
|
19178
19236
|
},
|
|
19179
19237
|
gtm_account: {
|
|
19180
19238
|
title: "Account",
|
|
19181
|
-
description: "Free
|
|
19239
|
+
description: "Free: balance, agent cap, recent spend or batch quote.",
|
|
19182
19240
|
paid: false,
|
|
19183
19241
|
capabilities: [],
|
|
19184
19242
|
input: accountInput
|
|
@@ -19223,7 +19281,7 @@ var agentAnswerSchema = external_exports.object({
|
|
|
19223
19281
|
var byteLength = (value) => new TextEncoder().encode(value).length;
|
|
19224
19282
|
var DEFAULT_NEXT = { tool: "gtm_account", args: {} };
|
|
19225
19283
|
function speakable(value) {
|
|
19226
|
-
const plain = value.replace(/[*`#>|~]/g, "").replace(/\s+/g, " ").trim();
|
|
19284
|
+
const plain = value.replace(/[*`#>|~]/g, "").replace(/\s+/g, " ").replace(/…[.!?]+/g, "\u2026").trim();
|
|
19227
19285
|
const first = plain.match(/^.*?(?:[.!?…](?=\s|$)|$)/)?.[0].trim() ?? plain;
|
|
19228
19286
|
const words = first.split(" ").filter(Boolean);
|
|
19229
19287
|
let sentence = words.length > SUMMARY_MAX_WORDS ? `${words.slice(0, SUMMARY_MAX_WORDS - 1).join(" ")}\u2026` : words.join(" ");
|
|
@@ -19382,8 +19440,12 @@ var clientMetadataDocumentSchema = external_exports.object({
|
|
|
19382
19440
|
client_id: external_exports.string(),
|
|
19383
19441
|
client_name: external_exports.string().trim().min(1).max(100).optional(),
|
|
19384
19442
|
redirect_uris: external_exports.array(external_exports.string()).min(1).max(10),
|
|
19385
|
-
token_endpoint_auth_method: external_exports.
|
|
19386
|
-
|
|
19443
|
+
token_endpoint_auth_method: external_exports.string().optional(),
|
|
19444
|
+
token_endpoint_auth_methods_supported: external_exports.array(external_exports.string()).optional()
|
|
19445
|
+
}).passthrough().refine(
|
|
19446
|
+
(document) => (document.token_endpoint_auth_method ?? "none") === "none" || document.token_endpoint_auth_methods_supported?.includes("none") === true,
|
|
19447
|
+
{ message: "Client must support token_endpoint_auth_method none", path: ["token_endpoint_auth_method"] }
|
|
19448
|
+
);
|
|
19387
19449
|
|
|
19388
19450
|
// ../contracts/src/agent-account.ts
|
|
19389
19451
|
var agentAccessSchema = external_exports.object({
|
|
@@ -19530,7 +19592,7 @@ var SPECS = {
|
|
|
19530
19592
|
research: { ...PAID },
|
|
19531
19593
|
signals: { location: { type: "string" }, company: { type: "string" }, limit: { type: "string" }, ...PAID },
|
|
19532
19594
|
results: { offset: { type: "string" }, csv: { type: "boolean" }, link: { type: "boolean" } },
|
|
19533
|
-
tools: { input: { type: "string" }, ...PAID },
|
|
19595
|
+
tools: { input: { type: "string" }, file: { type: "string" }, column: { type: "string" }, out: { type: "string" }, ...PAID },
|
|
19534
19596
|
account: { count: { type: "string" }, file: { type: "string" }, column: { type: "string" } }
|
|
19535
19597
|
};
|
|
19536
19598
|
var COMMAND_NAMES = Object.keys(SPECS);
|
|
@@ -19642,7 +19704,7 @@ function build2(name, values, positionals) {
|
|
|
19642
19704
|
const [action, ...words] = positionals;
|
|
19643
19705
|
const budget = paid(values, name);
|
|
19644
19706
|
if (action === "search" || action === "describe") {
|
|
19645
|
-
if (values.input !== void 0 || Object.keys(budget).length) throw new UsageError(`gtm tools ${action} is free and takes no --input or budget flags.`, name);
|
|
19707
|
+
if (values.input !== void 0 || values.file !== void 0 || Object.keys(budget).length) throw new UsageError(`gtm tools ${action} is free and takes no --input, --file or budget flags.`, name);
|
|
19646
19708
|
if (action === "search") {
|
|
19647
19709
|
if (!words.length) throw new UsageError("Give words to search for, like gtm tools search google.", name);
|
|
19648
19710
|
return { kind: "tool", tool: "gtm_tools", args: { action, query: words.join(" ") } };
|
|
@@ -19661,6 +19723,11 @@ function build2(name, values, positionals) {
|
|
|
19661
19723
|
}
|
|
19662
19724
|
if (!input2 || typeof input2 !== "object" || Array.isArray(input2)) throw new UsageError("--input needs a JSON object.", name);
|
|
19663
19725
|
}
|
|
19726
|
+
const file2 = str(values, "file");
|
|
19727
|
+
const column = str(values, "column");
|
|
19728
|
+
const out = str(values, "out");
|
|
19729
|
+
if (file2 === void 0 && (column !== void 0 || out !== void 0)) throw new UsageError("--column and --out need --file.", name);
|
|
19730
|
+
if (file2 !== void 0) return { kind: "tool-file", capability: words[0], input: input2 ?? {}, args: budget, file: file2, ...column !== void 0 ? { column } : {}, ...out !== void 0 ? { out } : {} };
|
|
19664
19731
|
return { kind: "tool", tool: "gtm_tools", args: { action, capability: words[0], ...input2 !== void 0 ? { input: input2 } : {}, ...budget } };
|
|
19665
19732
|
}
|
|
19666
19733
|
throw new UsageError("Use gtm tools search <words>, gtm tools describe <capability> or gtm tools run <capability>.", name);
|
|
@@ -19847,6 +19914,58 @@ function profilesFromCsv(text2, column) {
|
|
|
19847
19914
|
}
|
|
19848
19915
|
return list;
|
|
19849
19916
|
}
|
|
19917
|
+
function peopleFromCsv(text2, column, names) {
|
|
19918
|
+
if (names === "only") return { ...nameListAsProfiles(namesFromCsv(text2)), named: true };
|
|
19919
|
+
try {
|
|
19920
|
+
return { ...profilesFromCsv(text2, column), named: false };
|
|
19921
|
+
} catch (error61) {
|
|
19922
|
+
if (names === "never" || column !== void 0 || !(error61 instanceof FileInputError)) throw error61;
|
|
19923
|
+
return { ...nameListAsProfiles(namesFromCsv(text2)), named: true };
|
|
19924
|
+
}
|
|
19925
|
+
}
|
|
19926
|
+
function nameListAsProfiles(list) {
|
|
19927
|
+
return { profiles: list.people, rows: list.rows, duplicates: list.duplicates, invalid: 0, empty: list.empty, column: `${list.columns.name}, ${list.columns.company}` };
|
|
19928
|
+
}
|
|
19929
|
+
var NAME_HEADER = /^(full[ _-]?name|name|person|contact|contact[ _-]?name|lead|lead[ _-]?name)$/i;
|
|
19930
|
+
var FIRST_HEADER = /^first[ _-]?name$/i;
|
|
19931
|
+
var LAST_HEADER = /^last[ _-]?name$/i;
|
|
19932
|
+
var COMPANY_HEADER = /^(company|company[ _-]?name|organi[sz]ation|account|account[ _-]?name|employer|company[ _-]?domain|domain|website)$/i;
|
|
19933
|
+
var SEPARATOR = "";
|
|
19934
|
+
function namePair(key) {
|
|
19935
|
+
const [name = "", company = ""] = key.split(SEPARATOR);
|
|
19936
|
+
return { name, company };
|
|
19937
|
+
}
|
|
19938
|
+
function namesFromCsv(text2) {
|
|
19939
|
+
const table = parseCsv(text2).filter((row) => row.some((cell2) => cell2.trim() !== ""));
|
|
19940
|
+
if (!table.length) throw new FileInputError("The file has no rows.");
|
|
19941
|
+
const header = table[0].map((cell2) => cell2.trim());
|
|
19942
|
+
const find = (pattern) => header.findIndex((cell2) => pattern.test(cell2));
|
|
19943
|
+
const nameAt = find(NAME_HEADER);
|
|
19944
|
+
const firstAt = find(FIRST_HEADER);
|
|
19945
|
+
const lastAt = find(LAST_HEADER);
|
|
19946
|
+
const companyAt = find(COMPANY_HEADER);
|
|
19947
|
+
if (companyAt < 0 || nameAt < 0 && (firstAt < 0 || lastAt < 0)) {
|
|
19948
|
+
throw new FileInputError(`Could not find a column of LinkedIn profile URLs (name it with --column) or name and company columns (head the columns "name" and "company"); the columns are ${header.join(", ")}.`);
|
|
19949
|
+
}
|
|
19950
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19951
|
+
const list = { people: [], rows: table.length - 1, duplicates: 0, empty: 0, columns: { name: nameAt >= 0 ? header[nameAt] : `${header[firstAt]} + ${header[lastAt]}`, company: header[companyAt] } };
|
|
19952
|
+
for (const row of table.slice(1)) {
|
|
19953
|
+
const name = (nameAt >= 0 ? row[nameAt] ?? "" : `${row[firstAt] ?? ""} ${row[lastAt] ?? ""}`).replace(/\s+/g, " ").trim();
|
|
19954
|
+
const company = (row[companyAt] ?? "").trim();
|
|
19955
|
+
if (!name || !company) {
|
|
19956
|
+
list.empty += 1;
|
|
19957
|
+
continue;
|
|
19958
|
+
}
|
|
19959
|
+
const key = `${name}${SEPARATOR}${company}`;
|
|
19960
|
+
if (seen.has(key.toLowerCase())) {
|
|
19961
|
+
list.duplicates += 1;
|
|
19962
|
+
continue;
|
|
19963
|
+
}
|
|
19964
|
+
seen.add(key.toLowerCase());
|
|
19965
|
+
list.people.push(key);
|
|
19966
|
+
}
|
|
19967
|
+
return list;
|
|
19968
|
+
}
|
|
19850
19969
|
|
|
19851
19970
|
// src/output.ts
|
|
19852
19971
|
var LOGIN_NEXT = { tool: "login", args: {} };
|
|
@@ -19892,8 +20011,8 @@ async function contacts(session, command) {
|
|
|
19892
20011
|
const answer = await session.settle(await session.gateway.call("gtm_find_contacts", args));
|
|
19893
20012
|
return finish(session, command, answer, people ? [{ people: args.people, answer, replayed: answer.replayed === true, runCost: 0, cost: answer.cost }] : null, {});
|
|
19894
20013
|
}
|
|
19895
|
-
const list =
|
|
19896
|
-
if (!list.profiles.length) throw new UsageError(`No LinkedIn profiles found in ${command.file}.`, "contacts");
|
|
20014
|
+
const list = peopleFromCsv(await session.readInput(command.file, "contacts"), command.column, "fallback");
|
|
20015
|
+
if (!list.profiles.length) throw new UsageError(`No ${list.named ? "names with companies" : "LinkedIn profiles"} found in ${command.file}.`, "contacts");
|
|
19897
20016
|
const fileFields = {
|
|
19898
20017
|
file: command.file,
|
|
19899
20018
|
column: list.column ?? void 0,
|
|
@@ -19903,11 +20022,12 @@ async function contacts(session, command) {
|
|
|
19903
20022
|
skipped: list.invalid + list.empty
|
|
19904
20023
|
};
|
|
19905
20024
|
const options = { ...args.find ? { find: args.find } : {}, ...args.verify ? { verify: true } : {} };
|
|
20025
|
+
const tool2 = list.named ? { tool: "gtm_find_contacts", args: (people) => ({ named: people.map(namePair), ...options }), perPerson: perPersonCredits(options) + CAPABILITIES["profile-finder"].price.credits } : { tool: "gtm_find_contacts", args: (people) => ({ people, ...options }), perPerson: perPersonCredits(options) };
|
|
19906
20026
|
const rerun = (flags) => fileNext(command, options, flags);
|
|
19907
20027
|
const perCall = await session.gateway.peoplePerCall();
|
|
19908
20028
|
const maxCredits = args.max_credits;
|
|
19909
20029
|
if (args.dry_run || maxCredits === void 0) {
|
|
19910
|
-
const quoted = await quote(session, list.profiles, perCall,
|
|
20030
|
+
const quoted = await quote(session, list.profiles, perCall, tool2);
|
|
19911
20031
|
if ("refusal" in quoted) return session.emit(quoted.refusal, fileFields);
|
|
19912
20032
|
const people = plural(list.profiles.length, "person", "people");
|
|
19913
20033
|
const free = quoted.quote === 0;
|
|
@@ -19933,14 +20053,14 @@ async function contacts(session, command) {
|
|
|
19933
20053
|
}), fileFields);
|
|
19934
20054
|
}
|
|
19935
20055
|
}
|
|
19936
|
-
const run = await runBatches(session, list.profiles, perCall, maxCredits ?? null,
|
|
20056
|
+
const run = await runBatches(session, list.profiles, perCall, maxCredits ?? null, tool2, args.idempotency_key);
|
|
19937
20057
|
if (!run.batches.length && run.stop?.refusal?.status !== "error") {
|
|
19938
20058
|
return session.emit(run.refusal ?? shapeAnswer({
|
|
19939
20059
|
status: "refused",
|
|
19940
20060
|
reason: "over_max_credits",
|
|
19941
20061
|
balance: null,
|
|
19942
20062
|
next: rerun({ dry_run: true }),
|
|
19943
|
-
summary: `Nothing was sent: one person can cost up to ${plural(
|
|
20063
|
+
summary: `Nothing was sent: one person can cost up to ${plural(tool2.perPerson, "credit")}, above your --max-credits of ${maxCredits}.`
|
|
19944
20064
|
}), fileFields);
|
|
19945
20065
|
}
|
|
19946
20066
|
if (run.batches.length === 1 && !run.stop) {
|
|
@@ -19965,19 +20085,19 @@ function perPersonCredits(options) {
|
|
|
19965
20085
|
const find = options.find ?? ["email"];
|
|
19966
20086
|
return (find.includes("email") ? CAPABILITIES["email-finder"].price.credits : 0) + (options.verify ? CAPABILITIES["verify-email"].price.credits : 0) + (find.includes("phone") ? CAPABILITIES["phone-pilot"].price.credits : 0);
|
|
19967
20087
|
}
|
|
19968
|
-
async function quote(session, profiles, perCall,
|
|
20088
|
+
async function quote(session, profiles, perCall, tool2) {
|
|
19969
20089
|
let total = 0;
|
|
19970
20090
|
let balance = null;
|
|
19971
20091
|
for (let at = 0; at < profiles.length; at += perCall) {
|
|
19972
|
-
const answer = await session.gateway.call(
|
|
20092
|
+
const answer = await session.gateway.call(tool2.tool, { ...tool2.args(profiles.slice(at, at + perCall)), dry_run: true });
|
|
19973
20093
|
if (answer.status !== "quote") return { refusal: answer };
|
|
19974
20094
|
total += answer.quote ?? 0;
|
|
19975
20095
|
balance = answer.balance;
|
|
19976
20096
|
}
|
|
19977
20097
|
return { quote: total, balance };
|
|
19978
20098
|
}
|
|
19979
|
-
function batchKey(base,
|
|
19980
|
-
const hash2 = createHash("sha256").update(JSON.stringify(
|
|
20099
|
+
function batchKey(base, args) {
|
|
20100
|
+
const hash2 = createHash("sha256").update(JSON.stringify(args)).digest("hex");
|
|
19981
20101
|
if (!base) return `gtm-file-${hash2.slice(0, 32)}`;
|
|
19982
20102
|
const key = `${base}-${hash2.slice(0, 16)}`;
|
|
19983
20103
|
return key.length <= 128 ? key : `gtm-${createHash("sha256").update(key).digest("hex").slice(0, 40)}`;
|
|
@@ -19985,23 +20105,23 @@ function batchKey(base, people, options) {
|
|
|
19985
20105
|
function retryKey(key, runId) {
|
|
19986
20106
|
return `gtm-retry-${createHash("sha256").update(`${key}|${runId}`).digest("hex").slice(0, 40)}`;
|
|
19987
20107
|
}
|
|
19988
|
-
async function runBatches(session, profiles, perCall, budget,
|
|
19989
|
-
const perPerson =
|
|
20108
|
+
async function runBatches(session, profiles, perCall, budget, tool2, baseKey) {
|
|
20109
|
+
const perPerson = tool2.perPerson;
|
|
19990
20110
|
const batches = [];
|
|
19991
20111
|
let remaining = budget ?? 0;
|
|
19992
20112
|
let sent = 0;
|
|
19993
20113
|
let failedCost = 0;
|
|
19994
20114
|
let failedRunCost = 0;
|
|
19995
20115
|
const done = (stop, refusal = null, running = false) => ({ batches, stop, refusal, running, failedCost, failedRunCost });
|
|
20116
|
+
const retried = /* @__PURE__ */ new Set();
|
|
19996
20117
|
while (sent < profiles.length) {
|
|
19997
20118
|
const size = Math.min(perCall, profiles.length - sent, budget === null ? perCall : Math.floor(remaining / perPerson));
|
|
19998
20119
|
if (size <= 0) return done({ reason: "over_max_credits", refusal: null });
|
|
19999
20120
|
const people = profiles.slice(sent, sent + size);
|
|
20000
|
-
let key = batchKey(baseKey, people
|
|
20121
|
+
let key = batchKey(baseKey, tool2.args(people));
|
|
20001
20122
|
for (; ; ) {
|
|
20002
|
-
const first = await session.gateway.call(
|
|
20003
|
-
people,
|
|
20004
|
-
...options,
|
|
20123
|
+
const first = await session.gateway.call(tool2.tool, {
|
|
20124
|
+
...tool2.args(people),
|
|
20005
20125
|
...budget === null ? {} : { max_credits: Math.max(0, remaining) },
|
|
20006
20126
|
idempotency_key: key
|
|
20007
20127
|
});
|
|
@@ -20019,6 +20139,13 @@ async function runBatches(session, profiles, perCall, budget, options, baseKey)
|
|
|
20019
20139
|
key = retryKey(key, answer.run_id);
|
|
20020
20140
|
continue;
|
|
20021
20141
|
}
|
|
20142
|
+
if (answer.reason === "partial_failure" && first.replayed && answer.run_id && !retried.has(key)) {
|
|
20143
|
+
retried.add(key);
|
|
20144
|
+
failedRunCost += runCost;
|
|
20145
|
+
remaining -= runCost;
|
|
20146
|
+
key = retryKey(key, answer.run_id);
|
|
20147
|
+
continue;
|
|
20148
|
+
}
|
|
20022
20149
|
batches.push({ people, answer, replayed: first.replayed === true, runCost, cost: first.replayed ? 0 : runCost });
|
|
20023
20150
|
if (answer.status === "running") return done({ reason: "running", refusal: null }, null, true);
|
|
20024
20151
|
remaining -= runCost;
|
|
@@ -20042,7 +20169,7 @@ async function collectRows(session, batches) {
|
|
|
20042
20169
|
perBatch.push(data.map((cells) => Object.fromEntries(named.map((name, i) => [name, cells[i] ? cells[i] : null]))));
|
|
20043
20170
|
}
|
|
20044
20171
|
const all = columns ?? DEFAULT_COLUMNS;
|
|
20045
|
-
const rows = batches.flatMap((batch, i) => perBatch[i].length ? perBatch[i] : batch.people.map((
|
|
20172
|
+
const rows = batches.flatMap((batch, i) => perBatch[i].length ? perBatch[i] : batch.people.map((person) => ({ ...Object.fromEntries(all.map((name) => [name, null])), ...profileOf(person) ? { url: person } : namePair(person), status: batch.answer.status === "error" ? "error" : "not_found" })));
|
|
20046
20173
|
return { columns: all, rows: rows.map((row) => Object.fromEntries(all.map((name) => [name, row[name] ?? null]))) };
|
|
20047
20174
|
}
|
|
20048
20175
|
async function writeOut(session, path, table) {
|
|
@@ -20129,11 +20256,125 @@ async function combined(session, command, run, total, budget, rerun, fileFields)
|
|
|
20129
20256
|
return session.emit(answer, fields, stop && !run.running && !failed2 ? { exit: 3 } : {});
|
|
20130
20257
|
}
|
|
20131
20258
|
|
|
20259
|
+
// src/tools-file.ts
|
|
20260
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
20261
|
+
var plural2 = (n2, one, many = `${one}s`) => `${n2} ${n2 === 1 ? one : many}`;
|
|
20262
|
+
async function toolFile(session, command) {
|
|
20263
|
+
const definition = CAPABILITIES[command.capability];
|
|
20264
|
+
if (!definition?.batch) throw new UsageError(`gtm tools run ${command.capability} does not take --file; it runs one input at a time.`, "tools");
|
|
20265
|
+
if (["people", "profile", "name", "company"].some((field) => field in command.input)) throw new UsageError("Give the people with --file, not in --input.", "tools");
|
|
20266
|
+
const byName = "name" in definition.input.shape;
|
|
20267
|
+
const list = peopleFromCsv(await session.readInput(command.file, "tools"), command.column, byName ? "only" : "never");
|
|
20268
|
+
if (!list.profiles.length) throw new UsageError(`No ${byName ? "names with companies" : "LinkedIn profiles"} found in ${command.file}.`, "tools");
|
|
20269
|
+
const fileFields = {
|
|
20270
|
+
file: command.file,
|
|
20271
|
+
column: list.column ?? void 0,
|
|
20272
|
+
file_rows: list.rows,
|
|
20273
|
+
profiles: list.profiles.length,
|
|
20274
|
+
duplicates: list.duplicates,
|
|
20275
|
+
skipped: list.invalid + list.empty
|
|
20276
|
+
};
|
|
20277
|
+
const tool2 = {
|
|
20278
|
+
tool: "gtm_tools",
|
|
20279
|
+
args: (people2) => ({ action: "run", capability: command.capability, input: { ...command.input, people: byName ? people2.map(namePair) : people2 } }),
|
|
20280
|
+
perPerson: definition.price.credits
|
|
20281
|
+
};
|
|
20282
|
+
const rerun = (flags) => ({
|
|
20283
|
+
tool: "gtm_tools",
|
|
20284
|
+
args: {
|
|
20285
|
+
action: "run",
|
|
20286
|
+
capability: command.capability,
|
|
20287
|
+
file: command.file,
|
|
20288
|
+
...command.column !== void 0 ? { column: command.column } : {},
|
|
20289
|
+
...Object.keys(command.input).length ? { input: command.input } : {},
|
|
20290
|
+
...command.out !== void 0 ? { out: command.out } : {},
|
|
20291
|
+
...flags
|
|
20292
|
+
}
|
|
20293
|
+
});
|
|
20294
|
+
const maxCredits = command.args.max_credits;
|
|
20295
|
+
const perCall = await session.gateway.peoplePerCall();
|
|
20296
|
+
const people = plural2(list.profiles.length, "person", "people");
|
|
20297
|
+
if (command.args.dry_run || maxCredits === void 0) {
|
|
20298
|
+
const quoted = await quote(session, list.profiles, perCall, tool2);
|
|
20299
|
+
if ("refusal" in quoted) return session.emit(quoted.refusal, fileFields);
|
|
20300
|
+
const free = quoted.quote === 0;
|
|
20301
|
+
if (command.args.dry_run || !free) {
|
|
20302
|
+
return session.emit(shapeAnswer({
|
|
20303
|
+
status: command.args.dry_run ? "quote" : "refused",
|
|
20304
|
+
quote: quoted.quote,
|
|
20305
|
+
balance: quoted.balance,
|
|
20306
|
+
...command.args.dry_run ? {} : { reason: "max_credits_required" },
|
|
20307
|
+
next: rerun(free ? {} : { max_credits: quoted.quote }),
|
|
20308
|
+
summary: free ? `${people} cost nothing: this account already has their results; nothing was sent.` : command.args.dry_run ? `${people} would cost at most ${plural2(quoted.quote, "credit")}; nothing was sent.` : `Nothing was sent: this costs at most ${plural2(quoted.quote, "credit")}, so add --max-credits to run it.`
|
|
20309
|
+
}), fileFields);
|
|
20310
|
+
}
|
|
20311
|
+
}
|
|
20312
|
+
const run = await runBatches(session, list.profiles, perCall, maxCredits ?? null, tool2, command.args.idempotency_key);
|
|
20313
|
+
if (!run.batches.length) {
|
|
20314
|
+
return session.emit(run.refusal ?? run.stop?.refusal ?? shapeAnswer({
|
|
20315
|
+
status: "refused",
|
|
20316
|
+
reason: "over_max_credits",
|
|
20317
|
+
balance: null,
|
|
20318
|
+
next: rerun({ dry_run: true }),
|
|
20319
|
+
summary: `Nothing was sent: one person can cost up to ${plural2(tool2.perPerson, "credit")}, above your --max-credits of ${maxCredits}.`
|
|
20320
|
+
}), fileFields);
|
|
20321
|
+
}
|
|
20322
|
+
const sent = run.batches.reduce((sum, batch) => sum + batch.people.length, 0);
|
|
20323
|
+
let cost = run.batches.reduce((sum, batch) => sum + batch.cost, run.failedCost);
|
|
20324
|
+
let runCost = run.batches.reduce((sum, batch) => sum + batch.runCost, run.failedRunCost);
|
|
20325
|
+
const runIds = run.batches.map((batch) => batch.answer.run_id).filter((id) => !!id);
|
|
20326
|
+
const table = run.running ? null : await collectRows(session, run.batches);
|
|
20327
|
+
const errored = table?.rows.filter((row) => row.status === "error" && row.url).map((row) => row.url) ?? [];
|
|
20328
|
+
if (table && errored.length && !run.stop) {
|
|
20329
|
+
const left = maxCredits === void 0 ? null : Math.max(0, maxCredits - runCost);
|
|
20330
|
+
const retry = await runBatches(session, errored, perCall, left, tool2, `gtm-retry-${createHash2("sha256").update(runIds.join(",")).digest("hex").slice(0, 32)}`);
|
|
20331
|
+
const again = retry.batches.length && !retry.running ? await collectRows(session, retry.batches) : null;
|
|
20332
|
+
const byUrl = new Map(again?.rows.map((row) => [row.url, row]) ?? []);
|
|
20333
|
+
table.rows = table.rows.map((row) => row.status === "error" && byUrl.has(row.url) ? { ...row, ...byUrl.get(row.url) } : row);
|
|
20334
|
+
cost += retry.batches.reduce((sum, batch) => sum + batch.cost, retry.failedCost);
|
|
20335
|
+
runCost += retry.batches.reduce((sum, batch) => sum + batch.runCost, retry.failedRunCost);
|
|
20336
|
+
runIds.push(...retry.batches.map((batch) => batch.answer.run_id).filter((id) => !!id));
|
|
20337
|
+
}
|
|
20338
|
+
if (table && command.out) await writeOut(session, command.out, table);
|
|
20339
|
+
const found = table?.rows.filter((row) => row.status === "found").length ?? 0;
|
|
20340
|
+
const stillFailed = table?.rows.filter((row) => row.status === "error").length ?? 0;
|
|
20341
|
+
const unsent = list.profiles.length - sent;
|
|
20342
|
+
const failed2 = run.stop?.refusal?.status === "error" ? run.stop.refusal : null;
|
|
20343
|
+
const noun = definition.noun;
|
|
20344
|
+
const summary = run.running ? `Batch ${run.batches.length} is still running after ${sent} of ${people}; rerun this command to wait and continue.` : failed2 ? `Stopped after ${sent} of ${people}, ${unsent} not sent: ${failed2.summary}` : run.stop ? `Stopped after ${sent} of ${people} (${run.stop.refusal?.summary ?? "budget reached"}); found ${plural2(found, noun.replace(/s$/, ""), noun)} so far.` : `Found ${found} of ${plural2(sent, noun.replace(/s$/, ""), noun)} across ${plural2(run.batches.length, "batch", "batches")}; ${cost ? `${plural2(cost, "credit")} charged` : "nothing was charged"}${sent - found - stillFailed ? `, misses free` : ""}${stillFailed ? `; ${stillFailed} failed twice, so rerun later for them` : ""}.`;
|
|
20345
|
+
const columns = run.batches.find((batch) => batch.answer.columns.length)?.answer.columns ?? [...definition.preview, "status"];
|
|
20346
|
+
const rows = table?.rows ?? run.batches.flatMap((batch) => batch.answer.rows.map((cells) => Object.fromEntries(batch.answer.columns.map((name, i) => [name, cells[i] ?? null]))));
|
|
20347
|
+
const budgetFlag = maxCredits === void 0 ? {} : { max_credits: maxCredits };
|
|
20348
|
+
const next = failed2 || run.running || run.stop ? rerun(budgetFlag) : command.out && table ? ACCOUNT_NEXT : table ? rerun({ ...budgetFlag, out: `${command.file.replace(/\.csv$/i, "")}-${command.capability}.csv` }) : { tool: "gtm_results", args: { run_id: runIds.at(-1) } };
|
|
20349
|
+
const answer = shapeAnswer({
|
|
20350
|
+
status: failed2 ? "error" : run.running ? "running" : found || !table ? "completed" : "not_found",
|
|
20351
|
+
summary,
|
|
20352
|
+
run_id: runIds.length === 1 ? runIds[0] : null,
|
|
20353
|
+
cost,
|
|
20354
|
+
run_cost: runCost,
|
|
20355
|
+
balance: (failed2 ?? run.batches.at(-1)?.answer)?.balance ?? null,
|
|
20356
|
+
total: table?.rows.length ?? sent,
|
|
20357
|
+
label: noun,
|
|
20358
|
+
columns,
|
|
20359
|
+
rows,
|
|
20360
|
+
next,
|
|
20361
|
+
...run.stop && !run.running ? { reason: run.stop.reason } : {},
|
|
20362
|
+
...run.batches.every((batch) => batch.replayed) ? { replayed: true } : {}
|
|
20363
|
+
});
|
|
20364
|
+
return session.emit(answer, {
|
|
20365
|
+
...fileFields,
|
|
20366
|
+
batches: run.batches.length,
|
|
20367
|
+
run_ids: runIds.length > 1 ? runIds : void 0,
|
|
20368
|
+
unsent: unsent || void 0,
|
|
20369
|
+
out: command.out ? table ? command.out : "not written: still running" : void 0
|
|
20370
|
+
}, run.stop && !run.running && !failed2 ? { exit: 3 } : {});
|
|
20371
|
+
}
|
|
20372
|
+
|
|
20132
20373
|
// src/gateway.ts
|
|
20133
20374
|
import { randomUUID } from "node:crypto";
|
|
20134
20375
|
|
|
20135
20376
|
// src/version.ts
|
|
20136
|
-
var VERSION = "0.1.
|
|
20377
|
+
var VERSION = "0.1.3";
|
|
20137
20378
|
|
|
20138
20379
|
// src/gateway.ts
|
|
20139
20380
|
var CliError = class extends Error {
|
|
@@ -20332,7 +20573,8 @@ var TOPICS = {
|
|
|
20332
20573
|
tool("gtm_find_contacts"),
|
|
20333
20574
|
"",
|
|
20334
20575
|
"Options:",
|
|
20335
|
-
" --file PATH CSV or plain list of LinkedIn profile URLs or handles, any length",
|
|
20576
|
+
" --file PATH CSV or plain list of LinkedIn profile URLs or handles, any length;",
|
|
20577
|
+
" or a CSV with name and company columns, whose profiles are found first",
|
|
20336
20578
|
" --column NAME Column holding the profiles, when the CLI cannot tell",
|
|
20337
20579
|
" --run-id RUN The people from a gtm list run",
|
|
20338
20580
|
" --find email,phone What to find (default email)",
|
|
@@ -20357,7 +20599,7 @@ var TOPICS = {
|
|
|
20357
20599
|
tool("gtm_build_list"),
|
|
20358
20600
|
"",
|
|
20359
20601
|
"Options:",
|
|
20360
|
-
" --titles TITLE
|
|
20602
|
+
" --titles TITLE One job title, no commas; repeat for up to 5",
|
|
20361
20603
|
" --company DOMAIN Decision-makers at one company domain",
|
|
20362
20604
|
" --location PLACE Country or city",
|
|
20363
20605
|
" --business-type TYPE Local businesses, with --location",
|
|
@@ -20405,14 +20647,20 @@ var TOPICS = {
|
|
|
20405
20647
|
"Usage:",
|
|
20406
20648
|
" gtm tools search <words>",
|
|
20407
20649
|
" gtm tools describe <capability>",
|
|
20650
|
+
` gtm tools run seo-aeo-audit --input '{"url":"example.com"}' --max-credits 35`,
|
|
20408
20651
|
" gtm tools run <capability> --input '<json>' --max-credits N",
|
|
20652
|
+
` gtm tools run linkedin-activity --file leads.csv --input '{"topics":["automation"]}' --max-credits N [--out activity.csv]`,
|
|
20409
20653
|
"",
|
|
20410
20654
|
tool("gtm_tools"),
|
|
20411
20655
|
"",
|
|
20412
20656
|
`Capabilities: ${Object.keys(CAPABILITIES).join(", ")}.`,
|
|
20657
|
+
`--file works with ${Object.entries(CAPABILITIES).filter(([, c]) => "batch" in c && c.batch).map(([id]) => id).join(" and ")}: one job per person, run in budgeted batches; reruns replay finished batches free.`,
|
|
20413
20658
|
"",
|
|
20414
20659
|
"Options:",
|
|
20415
20660
|
" --input JSON The capability's input, as gtm tools describe shows",
|
|
20661
|
+
" --file PATH CSV or plain list of LinkedIn profile URLs or handles, any length",
|
|
20662
|
+
" --column NAME Column holding the profiles (found automatically when omitted)",
|
|
20663
|
+
" --out PATH Write every row to this CSV when all batches finish",
|
|
20416
20664
|
...PAID2
|
|
20417
20665
|
]
|
|
20418
20666
|
},
|
|
@@ -20700,7 +20948,7 @@ async function runCli(argv, io) {
|
|
|
20700
20948
|
} catch (error61) {
|
|
20701
20949
|
if (error61 instanceof CliError) return session.emit(errorAnswer(error61));
|
|
20702
20950
|
if (error61 instanceof UsageError) return usage(io, error61);
|
|
20703
|
-
if (error61 instanceof FileInputError) return usage(io, new UsageError(error61.message, command.kind === "quote-file" ? "account" : "contacts"));
|
|
20951
|
+
if (error61 instanceof FileInputError) return usage(io, new UsageError(error61.message, command.kind === "quote-file" ? "account" : command.kind === "tool-file" ? "tools" : "contacts"));
|
|
20704
20952
|
throw error61;
|
|
20705
20953
|
}
|
|
20706
20954
|
}
|
|
@@ -20720,6 +20968,8 @@ async function dispatch(session, command) {
|
|
|
20720
20968
|
return whoami(session);
|
|
20721
20969
|
case "contacts":
|
|
20722
20970
|
return contacts(session, command);
|
|
20971
|
+
case "tool-file":
|
|
20972
|
+
return toolFile(session, command);
|
|
20723
20973
|
case "results":
|
|
20724
20974
|
return results(session, command);
|
|
20725
20975
|
case "quote-file":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtmmaxing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "gtm: the GTMMAXING command line. Find contacts, build lead lists and research companies from a terminal or a coding agent, with credit caps on every paid call.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtm",
|
|
@@ -24,20 +24,21 @@
|
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=20"
|
|
26
26
|
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "node scripts/build.mjs",
|
|
29
|
+
"prepublishOnly": "pnpm build",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"lint": "eslint src test",
|
|
32
|
+
"test": "vitest run"
|
|
33
|
+
},
|
|
27
34
|
"devDependencies": {
|
|
35
|
+
"@found/contracts": "workspace:*",
|
|
28
36
|
"@types/node": "^24.0.0",
|
|
29
37
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
30
38
|
"@typescript-eslint/parser": "^8.46.4",
|
|
31
39
|
"esbuild": "0.28.1",
|
|
32
40
|
"eslint": "^9.39.2",
|
|
33
41
|
"typescript": "^5.9.3",
|
|
34
|
-
"vitest": "^4.1.11"
|
|
35
|
-
"@found/contracts": "0.1.0"
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "node scripts/build.mjs",
|
|
39
|
-
"typecheck": "tsc --noEmit",
|
|
40
|
-
"lint": "eslint src test",
|
|
41
|
-
"test": "vitest run"
|
|
42
|
+
"vitest": "^4.1.11"
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|