thinkwork-cli 0.12.16 → 0.12.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +517 -10403
- package/dist/commands/enterprise/templates/deploy-repo/docs/runbook.md +3 -8
- package/dist/commands/enterprise/templates/deploy-repo/terraform/main.tf +1 -184
- package/dist/drizzle/0050_brain_v0_entity_subtype.sql +2 -2
- package/dist/drizzle/0051_brain_v0_tenant_entity_pages.sql +6 -6
- package/dist/drizzle/0052_brain_v0_external_refs.sql +2 -2
- package/dist/drizzle/0053_brain_v0_unresolved_mentions_subtype.sql +2 -2
- package/dist/drizzle/0145_knowledge_graph_thread_ingest.sql +14 -14
- package/dist/drizzle/0146_knowledge_graph_source_scope.sql +1 -1
- package/dist/drizzle/0157_knowledge_graph_observations_source.sql +2 -2
- package/dist/drizzle/0158_wiki_tenant_scope.sql +1 -1
- package/dist/drizzle/0165_plugin_premium_entitlements.sql +2 -2
- package/dist/drizzle/{0166_company_brain_substrate_contract.sql → 0166_brain_substrate_contract.sql} +9 -9
- package/dist/drizzle/{0167_company_brain_artifact_manifest_runtime.sql → 0167_brain_artifact_manifest_runtime.sql} +5 -5
- package/dist/drizzle/0168_eval_skill_gate.sql +1 -1
- package/dist/drizzle/0183_okf_artifact_manifests.sql +1 -1
- package/dist/drizzle/0200_eval_results_execution_tier.sql +40 -0
- package/dist/drizzle/0201_brain_dream_runs.sql +72 -0
- package/dist/drizzle/0202_backfill_thread_participants_from_senders.sql +110 -0
- package/dist/drizzle/0203_threads_mode_override.sql +61 -0
- package/dist/drizzle/0204_thread_turns_triggering_message_id.sql +48 -0
- package/dist/drizzle/0205_routines_git_python.sql +185 -0
- package/dist/drizzle/0206_agent_loop_versions_routine_actions.sql +40 -0
- package/dist/drizzle/0207_tenant_credentials_github_repo_kind.sql +52 -0
- package/dist/drizzle/0208_knowledge_graph_neutral_identifiers.sql +253 -0
- package/dist/drizzle/0209_living_artifacts_schema.sql +109 -0
- package/dist/drizzle/0210_think137_automations_additive_schema.sql +113 -0
- package/dist/drizzle/0211_backfill_agent_loop_versions_target_spec.sql +120 -0
- package/dist/drizzle/0212_fold_webhooks_into_automations.sql +312 -0
- package/dist/drizzle/0213_agent_loop_versions_judge_evidence_nullable.sql +63 -0
- package/dist/drizzle/0214_think137_drop_judge_evidence_roi.sql +99 -0
- package/dist/drizzle/0215_agent_loop_versions_goal_worker_policy_nullable.sql +70 -0
- package/dist/drizzle/0216_drop_agent_loop_versions_goal_worker_policy.sql +81 -0
- package/dist/drizzle/0217_agents_capability_folder_dispatch.sql +12 -0
- package/dist/drizzle/0218_document_plates.sql +30 -0
- package/dist/drizzle/0219_document_section_waivers.sql +29 -0
- package/dist/drizzle/0220_artifacts_created_by_user.sql +21 -0
- package/dist/drizzle/0221_artifact_shares.sql +29 -0
- package/dist/drizzle/0221_workflow_interpreter_thin_slice.sql +71 -0
- package/dist/drizzle/0222_compliance_drainer_select_audit_events.sql +21 -0
- package/dist/drizzle/0223_document_conformance_reports.sql +38 -0
- package/dist/drizzle/0224_artifact_refresh_state.sql +11 -0
- package/dist/drizzle/0225_think216_agent_loop_convergence.sql +21 -0
- package/dist/drizzle/0226_drop_n8n_agent_step_runs.sql +6 -0
- package/dist/drizzle/0227_analyst_reader_role.sql +1055 -0
- package/dist/drizzle/0228_tenant_credentials_rds_iam_kind.sql +62 -0
- package/dist/drizzle/0229_analyst_reader_rds_iam_grant.sql +79 -0
- package/dist/drizzle/0230_analyst_rls.sql +1613 -0
- package/dist/drizzle/0231_cost_events_cache_write_enforcement_exempt.sql +11 -0
- package/dist/plugins/catalog/package.json +0 -1
- package/dist/plugins/catalog/src/__tests__/build-catalog.test.ts +0 -1
- package/dist/plugins/catalog/src/__tests__/catalog.test.ts +16 -8
- package/dist/plugins/catalog/src/__tests__/contracts.test.ts +56 -0
- package/dist/plugins/catalog/src/__tests__/plugin-package.test.ts +0 -2
- package/dist/plugins/catalog/src/__tests__/plugin-registry.test.ts +0 -5
- package/dist/plugins/catalog/src/contracts.ts +112 -0
- package/dist/plugins/catalog/src/registry/generated-first-party.ts +0 -6
- package/dist/plugins/n8n/README.md +4 -36
- package/dist/plugins/n8n/src/deployment/managed-app.ts +0 -17
- package/dist/plugins/n8n/src/manifest.ts +0 -5
- package/dist/plugins/n8n/terraform/n8n/main.tf +0 -26
- package/dist/plugins/n8n/terraform/n8n/outputs.tf +0 -5
- package/dist/plugins/n8n/terraform/n8n/variables.tf +0 -6
- package/dist/plugins/n8n/test/manifest.test.ts +0 -1
- package/dist/plugins/twenty/package.json +5 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-records.test.ts +232 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/mappers.test.ts +489 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/members-ensure.test.ts +199 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/provision-members-db.test.ts +43 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/schema-ensure.test.ts +230 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/twenty-client.test.ts +207 -0
- package/dist/plugins/twenty/scripts/lib/lastmile-reader.ts +282 -0
- package/dist/plugins/twenty/scripts/lib/load-attachments.ts +220 -0
- package/dist/plugins/twenty/scripts/lib/load-records.ts +680 -0
- package/dist/plugins/twenty/scripts/lib/mappers.ts +559 -0
- package/dist/plugins/twenty/scripts/lib/members-ensure.ts +381 -0
- package/dist/plugins/twenty/scripts/lib/provision-members-db.ts +191 -0
- package/dist/plugins/twenty/scripts/lib/schema-ensure.ts +425 -0
- package/dist/plugins/twenty/scripts/lib/twenty-client.ts +246 -0
- package/dist/plugins/twenty/scripts/migrate-lastmile.ts +610 -0
- package/dist/plugins/twenty/scripts/provision-twenty-members.ts +214 -0
- package/dist/plugins/twenty/src/manifest.ts +99 -0
- package/dist/plugins/twenty/terraform/twenty/README.md +1 -1
- package/dist/plugins/twenty/test/manifest.test.ts +12 -2
- package/dist/terraform/examples/greenfield/main.tf +90 -380
- package/dist/terraform/examples/greenfield/terraform.tfvars.example +0 -1
- package/dist/terraform/modules/app/agentcore-pi/README.md +1 -3
- package/dist/terraform/modules/app/agentcore-pi/main.tf +29 -38
- package/dist/terraform/modules/app/agentcore-pi/variables.tf +23 -15
- package/dist/terraform/modules/app/agentcore-runtime/main.tf +3 -3
- package/dist/terraform/modules/app/customer-domain/main.tf +16 -2
- package/dist/terraform/modules/app/deployment-control-plane/main.tf +5 -0
- package/dist/terraform/modules/app/deployment-control-plane/runner.py +85 -207
- package/dist/terraform/modules/app/deployment-control-plane/test_runner_bundle.py +56 -2
- package/dist/terraform/modules/app/hindsight-memory/main.tf +52 -4
- package/dist/terraform/modules/app/lambda-api/eval-fanout.tf +7 -0
- package/dist/terraform/modules/app/lambda-api/handlers.tf +493 -89
- package/dist/terraform/modules/app/lambda-api/iam-grouped.tf +215 -96
- package/dist/terraform/modules/app/lambda-api/main.tf +24 -5
- package/dist/terraform/modules/app/lambda-api/outputs.tf +19 -11
- package/dist/terraform/modules/app/lambda-api/variables.tf +94 -67
- package/dist/terraform/modules/app/ses-email/main.tf +14 -2
- package/dist/terraform/modules/app/workflow-interpreter-stepfunctions/main.tf +493 -0
- package/dist/terraform/modules/app/workflow-interpreter-stepfunctions/outputs.tf +34 -0
- package/dist/terraform/modules/app/workflow-interpreter-stepfunctions/variables.tf +32 -0
- package/dist/terraform/modules/data/aurora-postgres/main.tf +55 -0
- package/dist/terraform/modules/data/aurora-postgres/outputs.tf +15 -0
- package/dist/terraform/modules/data/s3-buckets/main.tf +26 -0
- package/dist/terraform/modules/thinkwork/README.md +0 -1
- package/dist/terraform/modules/thinkwork/main.tf +167 -446
- package/dist/terraform/modules/thinkwork/outputs.tf +2 -142
- package/dist/terraform/modules/thinkwork/variables.tf +55 -309
- package/dist/terraform/schema.graphql +4 -0
- package/dist/workspace-defaults/files/AGENTS.md +45 -31
- package/dist/workspace-defaults/files/CONTEXT.md +48 -4
- package/dist/workspace-defaults/files/GUARDRAILS.md +18 -0
- package/dist/workspace-defaults/files/MEMORY_GUIDE.md +32 -4
- package/dist/workspace-defaults/files/SPACE.md +34 -19
- package/dist/workspace-defaults/files/TOOLS.md +30 -0
- package/dist/workspace-defaults/files/skills/document-composer/SKILL.md +154 -0
- package/dist/workspace-defaults/files/skills/document-composer/references/authoring-rules.md +101 -0
- package/package.json +1 -1
- package/dist/plugins/company-brain/README.md +0 -37
- package/dist/plugins/company-brain/package.json +0 -33
- package/dist/plugins/company-brain/runtime/cognee/Dockerfile +0 -11
- package/dist/plugins/company-brain/smoke/cognee-managed-app-smoke.mjs +0 -458
- package/dist/plugins/company-brain/smoke/cognee-memory-cutover-smoke.mjs +0 -539
- package/dist/plugins/company-brain/smoke/company-brain-context-engine-smoke.mjs +0 -312
- package/dist/plugins/company-brain/smoke/company-brain-operations-smoke.mjs +0 -449
- package/dist/plugins/company-brain/smoke/company-brain-plugin-smoke.mjs +0 -655
- package/dist/plugins/company-brain/smoke/hindsight-memory-isolation-smoke.mjs +0 -474
- package/dist/plugins/company-brain/src/api/cognee-client.ts +0 -896
- package/dist/plugins/company-brain/src/api/cognee-cluster-identity.ts +0 -49
- package/dist/plugins/company-brain/src/api/cognee-memory-scope.ts +0 -84
- package/dist/plugins/company-brain/src/api/context-engine-provider.ts +0 -888
- package/dist/plugins/company-brain/src/api/migration.ts +0 -665
- package/dist/plugins/company-brain/src/deployment/cognee-managed-app.ts +0 -396
- package/dist/plugins/company-brain/src/index.ts +0 -62
- package/dist/plugins/company-brain/src/manifest.ts +0 -112
- package/dist/plugins/company-brain/terraform/cognee/README.md +0 -263
- package/dist/plugins/company-brain/terraform/cognee/main.tf +0 -766
- package/dist/plugins/company-brain/terraform/cognee/outputs.tf +0 -144
- package/dist/plugins/company-brain/terraform/cognee/variables.tf +0 -402
- package/dist/plugins/company-brain/test/api/cognee-client.test.ts +0 -562
- package/dist/plugins/company-brain/test/api/cognee-memory-scope.test.ts +0 -74
- package/dist/plugins/company-brain/test/api/context-engine-provider.test.ts +0 -447
- package/dist/plugins/company-brain/test/api/migration.test.ts +0 -465
- package/dist/plugins/company-brain/test/manifest.test.ts +0 -95
- package/dist/plugins/company-brain/tsconfig.json +0 -8
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
COMPANY,
|
|
5
|
+
emptyCounters,
|
|
6
|
+
mirrorDeletions,
|
|
7
|
+
upsertRecords,
|
|
8
|
+
} from "../load-records";
|
|
9
|
+
import { contentHash } from "../mappers";
|
|
10
|
+
import type { MappedRecord } from "../mappers";
|
|
11
|
+
import type { TwentyClient } from "../twenty-client";
|
|
12
|
+
|
|
13
|
+
function mapped(
|
|
14
|
+
sourceId: string,
|
|
15
|
+
input: Record<string, unknown>,
|
|
16
|
+
): MappedRecord {
|
|
17
|
+
return { sourceId, input: { ...input, sourceId }, warnings: [] };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface FakeExisting {
|
|
21
|
+
id: string;
|
|
22
|
+
sourceId: string;
|
|
23
|
+
sourceHash: string | null;
|
|
24
|
+
deletedAt: string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Fake client answering the sourceId-lookup queries and recording mutations. */
|
|
28
|
+
function fakeClient(existing: FakeExisting[]): {
|
|
29
|
+
client: TwentyClient;
|
|
30
|
+
mutations: Array<{ query: string; variables: Record<string, unknown> }>;
|
|
31
|
+
} {
|
|
32
|
+
const mutations: Array<{
|
|
33
|
+
query: string;
|
|
34
|
+
variables: Record<string, unknown>;
|
|
35
|
+
}> = [];
|
|
36
|
+
const client = {
|
|
37
|
+
requestWithRetry: vi.fn(
|
|
38
|
+
async (
|
|
39
|
+
_path: string,
|
|
40
|
+
query: string,
|
|
41
|
+
variables: {
|
|
42
|
+
filter?: { deletedAt?: unknown; sourceId?: { in?: string[] } };
|
|
43
|
+
},
|
|
44
|
+
) => {
|
|
45
|
+
const wantDeleted = Boolean(variables.filter?.deletedAt);
|
|
46
|
+
const ids = variables.filter?.sourceId?.in ?? [];
|
|
47
|
+
const nodes = existing.filter(
|
|
48
|
+
(record) =>
|
|
49
|
+
ids.includes(record.sourceId) &&
|
|
50
|
+
(wantDeleted ? !!record.deletedAt : !record.deletedAt),
|
|
51
|
+
);
|
|
52
|
+
const key = /companies/.test(query) ? "companies" : "records";
|
|
53
|
+
return { [key]: { edges: nodes.map((node) => ({ node })) } };
|
|
54
|
+
},
|
|
55
|
+
),
|
|
56
|
+
requestOnce: vi.fn(
|
|
57
|
+
async (
|
|
58
|
+
_path: string,
|
|
59
|
+
query: string,
|
|
60
|
+
variables: Record<string, unknown>,
|
|
61
|
+
) => {
|
|
62
|
+
mutations.push({ query, variables });
|
|
63
|
+
if (query.includes("createCompanies")) {
|
|
64
|
+
const data = (variables as { data: Array<{ sourceId: string }> })
|
|
65
|
+
.data;
|
|
66
|
+
return {
|
|
67
|
+
createCompanies: data.map((row, index) => ({
|
|
68
|
+
id: `new-${row.sourceId}-${index}`,
|
|
69
|
+
sourceId: row.sourceId,
|
|
70
|
+
})),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return { ok: true };
|
|
74
|
+
},
|
|
75
|
+
),
|
|
76
|
+
} as unknown as TwentyClient;
|
|
77
|
+
return { client, mutations };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
describe("upsertRecords branches (AE1)", () => {
|
|
81
|
+
it("creates missing, updates changed, skips unchanged, restores deleted", async () => {
|
|
82
|
+
const unchanged = mapped("account:a1", { name: "Same" });
|
|
83
|
+
const changed = mapped("account:a2", { name: "New name" });
|
|
84
|
+
const missing = mapped("account:a3", { name: "Brand new" });
|
|
85
|
+
const revived = mapped("account:a4", { name: "Back" });
|
|
86
|
+
|
|
87
|
+
const { client, mutations } = fakeClient([
|
|
88
|
+
{
|
|
89
|
+
id: "t1",
|
|
90
|
+
sourceId: "account:a1",
|
|
91
|
+
sourceHash: contentHash(unchanged.input),
|
|
92
|
+
deletedAt: null,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "t2",
|
|
96
|
+
sourceId: "account:a2",
|
|
97
|
+
sourceHash: "stale-hash",
|
|
98
|
+
deletedAt: null,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "t4",
|
|
102
|
+
sourceId: "account:a4",
|
|
103
|
+
sourceHash: contentHash(revived.input),
|
|
104
|
+
deletedAt: "2026-07-01T00:00:00Z",
|
|
105
|
+
},
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
const counters = emptyCounters();
|
|
109
|
+
const ids = await upsertRecords({
|
|
110
|
+
client,
|
|
111
|
+
entity: COMPANY,
|
|
112
|
+
mapped: [unchanged, changed, missing, revived],
|
|
113
|
+
dryRun: false,
|
|
114
|
+
counters,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(counters).toMatchObject({
|
|
118
|
+
sourceTotal: 4,
|
|
119
|
+
created: 1,
|
|
120
|
+
updated: 1,
|
|
121
|
+
restored: 1,
|
|
122
|
+
skipped: 1,
|
|
123
|
+
failed: 0,
|
|
124
|
+
});
|
|
125
|
+
expect(ids.get("account:a3")).toMatch(/^new-/);
|
|
126
|
+
// Restore fired before the update for the revived record (KTD3 revival).
|
|
127
|
+
const restoreIndex = mutations.findIndex((m) =>
|
|
128
|
+
m.query.includes("restoreCompany"),
|
|
129
|
+
);
|
|
130
|
+
const updateIndexes = mutations
|
|
131
|
+
.map((m, i) => (m.query.includes("updateCompany") ? i : -1))
|
|
132
|
+
.filter((i) => i >= 0);
|
|
133
|
+
expect(restoreIndex).toBeGreaterThanOrEqual(0);
|
|
134
|
+
expect(Math.max(...updateIndexes)).toBeGreaterThan(restoreIndex);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("dry-run plans mutations without calling any mutation endpoint", async () => {
|
|
138
|
+
const { client, mutations } = fakeClient([]);
|
|
139
|
+
const counters = emptyCounters();
|
|
140
|
+
await upsertRecords({
|
|
141
|
+
client,
|
|
142
|
+
entity: COMPANY,
|
|
143
|
+
mapped: [mapped("account:a1", { name: "X" })],
|
|
144
|
+
dryRun: true,
|
|
145
|
+
counters,
|
|
146
|
+
});
|
|
147
|
+
expect(mutations).toHaveLength(0);
|
|
148
|
+
expect(counters.created).toBe(1);
|
|
149
|
+
expect(counters.plannedMutations).toEqual(["create company account:a1"]);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("aborts loudly when two live records share a sourceId", async () => {
|
|
153
|
+
const dupe: FakeExisting[] = [
|
|
154
|
+
{ id: "t1", sourceId: "account:a1", sourceHash: null, deletedAt: null },
|
|
155
|
+
{ id: "t2", sourceId: "account:a1", sourceHash: null, deletedAt: null },
|
|
156
|
+
];
|
|
157
|
+
const { client } = fakeClient(dupe);
|
|
158
|
+
const counters = emptyCounters();
|
|
159
|
+
await expect(
|
|
160
|
+
upsertRecords({
|
|
161
|
+
client,
|
|
162
|
+
entity: COMPANY,
|
|
163
|
+
mapped: [mapped("account:a1", { name: "X" })],
|
|
164
|
+
dryRun: false,
|
|
165
|
+
counters,
|
|
166
|
+
}),
|
|
167
|
+
).rejects.toThrow(/share sourceId/);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe("mirrorDeletions (AE2 / KTD7)", () => {
|
|
172
|
+
function clientWithAll(
|
|
173
|
+
records: Array<{ id: string; sourceId: string | null }>,
|
|
174
|
+
) {
|
|
175
|
+
const mutations: Array<{ variables: Record<string, unknown> }> = [];
|
|
176
|
+
const client = {
|
|
177
|
+
requestWithRetry: vi.fn(async () => ({
|
|
178
|
+
companies: {
|
|
179
|
+
edges: records.map((node) => ({ node })),
|
|
180
|
+
pageInfo: { hasNextPage: false, endCursor: null },
|
|
181
|
+
},
|
|
182
|
+
})),
|
|
183
|
+
requestOnce: vi.fn(
|
|
184
|
+
async (_p: string, _q: string, variables: Record<string, unknown>) => {
|
|
185
|
+
mutations.push({ variables });
|
|
186
|
+
return { deleteCompanies: [] };
|
|
187
|
+
},
|
|
188
|
+
),
|
|
189
|
+
} as unknown as TwentyClient;
|
|
190
|
+
return { client, mutations };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
it("soft-deletes only migration-owned records that vanished from the source", async () => {
|
|
194
|
+
const { client, mutations } = clientWithAll([
|
|
195
|
+
{ id: "t1", sourceId: "account:alive" },
|
|
196
|
+
{ id: "t2", sourceId: "account:gone" },
|
|
197
|
+
{ id: "t3", sourceId: null }, // native Twenty record — never a candidate
|
|
198
|
+
{ id: "t4", sourceId: "other:thing" }, // not owned by this migration
|
|
199
|
+
]);
|
|
200
|
+
const counters = emptyCounters();
|
|
201
|
+
await mirrorDeletions({
|
|
202
|
+
client,
|
|
203
|
+
entity: COMPANY,
|
|
204
|
+
liveSourceIds: new Set(["account:alive"]),
|
|
205
|
+
ownedPrefixes: ["account:"],
|
|
206
|
+
dryRun: false,
|
|
207
|
+
counters,
|
|
208
|
+
});
|
|
209
|
+
expect(counters.deleted).toBe(1);
|
|
210
|
+
expect(mutations).toHaveLength(1);
|
|
211
|
+
expect(mutations[0].variables).toEqual({ filter: { id: { in: ["t2"] } } });
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("dry-run lists the would-be deletions", async () => {
|
|
215
|
+
const { client, mutations } = clientWithAll([
|
|
216
|
+
{ id: "t2", sourceId: "account:gone" },
|
|
217
|
+
]);
|
|
218
|
+
const counters = emptyCounters();
|
|
219
|
+
await mirrorDeletions({
|
|
220
|
+
client,
|
|
221
|
+
entity: COMPANY,
|
|
222
|
+
liveSourceIds: new Set(),
|
|
223
|
+
ownedPrefixes: ["account:"],
|
|
224
|
+
dryRun: true,
|
|
225
|
+
counters,
|
|
226
|
+
});
|
|
227
|
+
expect(mutations).toHaveLength(0);
|
|
228
|
+
expect(counters.plannedMutations).toEqual([
|
|
229
|
+
"soft-delete company account:gone",
|
|
230
|
+
]);
|
|
231
|
+
});
|
|
232
|
+
});
|