ente-cli 0.4.122 → 0.4.123

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/SKILL.md CHANGED
@@ -237,6 +237,9 @@ ente list add "<list>" [--space "<space>"] --title "…" [--attr k=v ...] [--key
237
237
  ente list update "<list>" <rowId> [--attr k=v ...] [--title "…"] [--json] # empty value clears a cell
238
238
  ente list import "<list>" [--space "<space>"] --file rows.jsonl --key <textColumn> [--dry-run] [--concurrency 4] [--json] # {"title","attrs","content"} per line → created/updated/unchanged
239
239
  ente list show "<list>" [--all | --cursor <nextCursor>] [--limit 100] [--where k=v ...] [--view] [--json] # all rows by default; --view = table's saved filters
240
+ # --where and --key run on the server; key imports probe submitted keys, independent of saved filters.
241
+ # Columns bind space-wide field IDs/types/options. Text and JSON match exactly; typed values match normalized.
242
+ # Refresh pagination after ACTIVITY_FIELD_CURSOR_INVALID. Ordered consumers fall back until their metadata migration is ready.
240
243
  # Rows are activities: trash with `ente activity delete <rowId>`, promote with `ente activity update <rowId> --entity-add "<entity>"`. Guide: playbooks/database-list-sync.md
241
244
 
242
245
  # Activity agendas (all activity types)
@@ -989,7 +992,7 @@ Entity exact-value lookup: `ente entity list --field "External ID=Case=ID"`. The
989
992
 
990
993
  Activity field lookup uses the server index: `ente activity list --type task --field "t3_thread=t3code://threads/<env>/<id>" --profile ente-operator`. For the credential's own agent queue, use `ente agent tasks list --field "t3_thread=t3code://threads/<env>/<id>" --profile ente-operator`. `--attr` is an alias for `--field` on these two commands. Repeat the option for AND matching (at most ten filters). The first `=` separates label and value, preserving subsequent equals signs. Activity list also accepts `--space` and `--entity` to narrow the indexed result. History cursors and `--min-count` cannot be combined with a field lookup.
991
994
 
992
- Activity definitions are shared across a space. Writers create definitions implicitly through the compatibility `attributes` write. Before first verified readiness, legacy attributes retain their existing write behavior; incompatible provisional projections defer and keep lookup closed. After first readiness, existing definitions validate subsequent values, including during later re-verification. Invalid typed writes reject atomically with `ACTIVITY_FIELD_VALUE_INVALID` (`FAILED_PRECONDITION`); vocabulary/byte caps use `ACTIVITY_FIELD_LIMIT_EXCEEDED` (`LIMIT_EXCEEDED`). Historical select options remain valid even if the current board omits them. See `docs/activity-fields-migration.md` for the bounds and bridge procedure. Types include text, JSON, email, phone, URL, date, postal-address, salutation, job-title, number, boolean, single-select and multi-select. Text and JSON match the stored string exactly, including case and whitespace. All other types match their normalized value; `Foo@X.com` finds `foo@x.com`. JSON lookup values use serialized JSON, so a JSON string is written as `"value"`.
995
+ Activity definitions are shared across a space. Writers create definitions implicitly through the compatibility `attributes` write. Before first verified readiness, legacy attributes retain their existing write behavior; incompatible provisional projections defer and keep lookup closed. After first readiness, existing definitions validate subsequent values, including during later re-verification. Invalid typed writes reject atomically with `ACTIVITY_FIELD_VALUE_INVALID` (`FAILED_PRECONDITION`); vocabulary/byte caps use `ACTIVITY_FIELD_LIMIT_EXCEEDED` (`LIMIT_EXCEEDED`). Empty or whitespace-only strings clear a canonical value while preserving the legacy cell. A string in a multi-select field is one literal selection, never delimiter-split, and adds its option implicitly within existing limits. Unknown single-select options still reject. Case/separator aliases share a definition; the compatibility attributes view retains the original stored key spelling. Historical select options remain valid even if the current board omits them. See `docs/activity-fields-migration.md` for the bounds and bridge procedure. Types include text, JSON, email, phone, URL, date, postal-address, salutation, job-title, number, boolean, single-select and multi-select. Text and JSON match the stored string exactly, including case and whitespace. All other types match their normalized value; `Foo@X.com` finds `foo@x.com`. JSON lookup values use serialized JSON, so a JSON string is written as `"value"`.
993
996
 
994
997
  REST `GET /api/external/activities` and `/api/external/tasks` accept URL-encoded JSON `field={"label":"t3_thread","value":"Case=ID"}`, or an array for AND. MCP `listActivities`/`activities_list`, `listTasks`/`tasks_list`, and `agent_tasks` (`operation: "list"`) use the same field shape. List/get results include `fields` (value ID, definition ID, label, type and stored string) once verification completes. `fieldIndexReady: false` withholds this array before verification. Indexed lookups fail with `ACTIVITY_FIELD_INDEX_NOT_READY` until the deployment's backfill is verified; do not replace this failure with a client scan. Candidate and output budgets fail explicitly instead of returning an incomplete field result. Legacy `attributes` remains the read/write compatibility view through phase 4.
995
998
 
package/dist/cli.mjs CHANGED
@@ -27854,7 +27854,15 @@ var activityFieldFilterSchema = external_exports.strictObject({ label: external_
27854
27854
  var activityFieldFiltersSchema = external_exports.union([activityFieldFilterSchema, external_exports.array(activityFieldFilterSchema).min(1).max(10)]);
27855
27855
  var activityFieldFilterValidator = v.object({ label: v.string(), value: v.string() });
27856
27856
  var activityFieldFiltersValidator = v.union(activityFieldFilterValidator, v.array(activityFieldFilterValidator));
27857
- var activityFieldReadFields = { fields: v.optional(v.array(externalActivityFieldValueValidator)), fieldIndexReady: v.optional(v.boolean()) };
27857
+ var activityFieldReadFields = { fields: v.optional(v.array(externalActivityFieldValueValidator)), fieldIndexReady: v.optional(v.boolean()), fieldConsumerReady: v.optional(v.boolean()) };
27858
+ var activityFieldPlanSummaryValidator = v.object({
27859
+ variants: v.array(v.object({ label: v.string(), count: v.number(), at: v.number(), id: v.string() })),
27860
+ types: v.array(activityFieldTypeValidator),
27861
+ textBoolean: v.boolean(),
27862
+ textNumeric: v.boolean(),
27863
+ configured: v.optional(v.object({ label: v.string(), type: activityFieldTypeValidator, at: v.number(), id: v.string() })),
27864
+ options: v.optional(v.array(activityFieldOptionValidator))
27865
+ });
27858
27866
  var MAX_ACTIVITY_FIELD_DEFINITION_READ_BYTES = 6 * 1024 * 1024;
27859
27867
 
27860
27868
  // ../packages/shared/src/activity-dates.ts
@@ -28690,7 +28698,7 @@ function parseOperationAttrs(operation, pairs) {
28690
28698
  }
28691
28699
 
28692
28700
  // ente/version.ts
28693
- var VERSION = "0.4.122";
28701
+ var VERSION = "0.4.123";
28694
28702
 
28695
28703
  // ente/branding.ts
28696
28704
  var NPM_REGISTRY = "https://registry.npmjs.org";
@@ -44395,6 +44403,7 @@ var databaseSelectOptionValidator = v.object({
44395
44403
  color: v.optional(v.string())
44396
44404
  });
44397
44405
  var entityDatabaseColumnValidator = v.object({
44406
+ fieldIds: v.optional(v.array(v.id("fields"))),
44398
44407
  key: v.string(),
44399
44408
  label: v.optional(v.string()),
44400
44409
  type: databaseAttributeTypeValidator,
@@ -44461,14 +44470,15 @@ var databaseViewContracts = {
44461
44470
  }
44462
44471
  };
44463
44472
  var databaseCellWriteContract = {
44464
- args: v.object({ activityId: v.id("activities"), key: v.string(), value: databaseAttributeValueValidator }),
44473
+ args: v.object({ activityId: v.id("activities"), fieldId: v.optional(v.id("fields")), fieldIds: v.optional(v.array(v.id("fields"))), key: v.string(), value: databaseAttributeValueValidator }),
44465
44474
  result: v.null()
44466
44475
  };
44467
44476
  var databaseRowsArgs = v.object({
44468
44477
  entityId: v.id("entities"),
44469
44478
  lensSpaceId: v.optional(v.id("spaces")),
44470
44479
  paginationOpts: paginationOptsValidator,
44471
- ignoreViewFilters: v.optional(v.boolean())
44480
+ ignoreViewFilters: v.optional(v.boolean()),
44481
+ where: v.optional(v.array(v.object({ key: v.string(), value: databaseAttributeValueValidator })))
44472
44482
  });
44473
44483
  function createDatabaseConfigurationContracts(owning) {
44474
44484
  return {
@@ -44668,16 +44678,6 @@ function parseWhere(columns, specs, listName) {
44668
44678
  return { key, value: coerceValue(column, spec.slice(eq + 1)) };
44669
44679
  });
44670
44680
  }
44671
- function matchesWhere(attributes2, clauses) {
44672
- const attrs = attributes2 ?? {};
44673
- return clauses.every(({ key, value }) => {
44674
- const cell = attrs[key];
44675
- if (Array.isArray(value) && value.length > 0) {
44676
- return Array.isArray(cell) && value.every((v3) => cell.includes(v3));
44677
- }
44678
- return sameValue(cell, value);
44679
- });
44680
- }
44681
44681
  function planUpsert(existing, inputs, keyColumn) {
44682
44682
  const byKey = /* @__PURE__ */ new Map();
44683
44683
  for (const row of existing) {
@@ -44844,8 +44844,8 @@ async function databaseWrite(call) {
44844
44844
  throw safe;
44845
44845
  }
44846
44846
  }
44847
- function cellArgs(activityId2, key, value) {
44848
- return parseDatabaseProtocolInput("activities:setAttributeValue", databaseCellWriteContract.args, { activityId: activityId2, key, value });
44847
+ function cellArgs(activityId2, key, value, column) {
44848
+ return parseDatabaseProtocolInput("activities:setAttributeValue", databaseCellWriteContract.args, { activityId: activityId2, key, value, ...column?.fieldIds?.length ? { fieldIds: column.fieldIds } : {} });
44849
44849
  }
44850
44850
  function titleArgs(activityId2, title4) {
44851
44851
  const request = parseActivityWriteRequest("updateActivityTitle", { activityId: activityId2, title: title4 });
@@ -44877,13 +44877,14 @@ async function loadList(caller, listNameOrId) {
44877
44877
  }
44878
44878
  };
44879
44879
  }
44880
- async function fetchAllRows(caller, entityId2) {
44880
+ async function fetchMatchingRows(caller, entityId2, where) {
44881
44881
  const rows = [];
44882
44882
  let cursor3 = null;
44883
44883
  for (; ; ) {
44884
44884
  const res = databaseListPage(await caller.query(listRows, parseDatabaseProtocolInput("database rows", databaseRowsArgs, {
44885
44885
  entityId: entityId2,
44886
44886
  ignoreViewFilters: true,
44887
+ where,
44887
44888
  paginationOpts: { numItems: ROW_PAGE_SIZE, cursor: cursor3 }
44888
44889
  })));
44889
44890
  rows.push(...res.page);
@@ -44891,6 +44892,27 @@ async function fetchAllRows(caller, entityId2) {
44891
44892
  cursor3 = res.continueCursor;
44892
44893
  }
44893
44894
  }
44895
+ async function fetchRowsForKeys(caller, entityId2, inputs, key) {
44896
+ const rows = /* @__PURE__ */ new Map();
44897
+ const matchedKeys = /* @__PURE__ */ new Map();
44898
+ const values = new Map(inputs.map((input2) => [JSON.stringify(input2.attributes[key]), input2.attributes[key]]));
44899
+ for (const value of values.values()) {
44900
+ if (typeof value !== "string" || !value.trim()) continue;
44901
+ const matches = await fetchMatchingRows(caller, entityId2, [{ key, value }]);
44902
+ for (const row of matches) {
44903
+ if (matchedKeys.has(row._id) && matchedKeys.get(row._id) !== value) throw new Error(`Multiple input keys resolve to row ${row._id}; use one key value before syncing.`);
44904
+ matchedKeys.set(row._id, value);
44905
+ const keyed = structuredClone(row);
44906
+ keyed.attributes = { ...row.attributes, [key]: value };
44907
+ rows.set(row._id, keyed);
44908
+ }
44909
+ if (!matches.length) {
44910
+ const titles = new Set(inputs.filter((input2) => input2.attributes[key] === value && input2.title !== void 0).map((input2) => input2.title));
44911
+ for (const title4 of titles) for (const row of await fetchMatchingRows(caller, entityId2, [{ key, value: null }, { key: "title", value: title4 }])) rows.set(row._id, row);
44912
+ }
44913
+ }
44914
+ return [...rows.values()];
44915
+ }
44894
44916
  async function resolveOwnerSpace(caller, space3) {
44895
44917
  if (!space3?.trim()) throw new Error("New list rows require --space (name or ID), including dry runs.");
44896
44918
  return resolveSpaceByNameC(caller, space3);
@@ -44903,6 +44925,7 @@ function rowJson(row) {
44903
44925
  completed: row.completed ?? false,
44904
44926
  createdAt: row._creationTime,
44905
44927
  attributes: row.attributes ?? {},
44928
+ ...row.fields ? { fields: row.fields, fieldIndexReady: row.fieldIndexReady } : {},
44906
44929
  entities: (row.entityDetails ?? []).filter((e) => e !== null).map((e) => ({ entityId: e._id, name: e.name }))
44907
44930
  };
44908
44931
  }
@@ -44926,7 +44949,7 @@ async function applyStep(ctx, step, progress) {
44926
44949
  rowId = await progress.write("create", () => databaseWrite(() => caller.mutationUnqueued(activitiesCreate3, args)), (raw) => graphResult(graphId2, raw), "activityId");
44927
44950
  }
44928
44951
  for (const [index, [key, value]] of orderedCells(ctx, step).entries()) {
44929
- const args = cellArgs(rowId, key, value);
44952
+ const args = cellArgs(rowId, key, value, ctx.columns.find((column) => column.key === key));
44930
44953
  await progress.write(`cell:${index + 1}`, () => databaseWrite(() => caller.mutationUnqueued(setAttributeValue, args)), (raw) => parseOperationResult("activities:setAttributeValue", databaseCellWriteContract.result, raw));
44931
44954
  }
44932
44955
  return rowId;
@@ -45086,12 +45109,12 @@ var ListAdd = class extends ProfileCommand {
45086
45109
  ...content !== void 0 ? { content } : {}
45087
45110
  };
45088
45111
  if (this.key !== void 0) columnOrThrow(view.columns, this.key, entity5.name);
45089
- const existing = this.key !== void 0 ? (await fetchAllRows(caller, entityId2)).map(toExisting) : [];
45112
+ const existing = this.key !== void 0 ? (await fetchRowsForKeys(caller, entityId2, [input2], this.key)).map(toExisting) : [];
45090
45113
  const keyColumn = this.key ?? "";
45091
45114
  const step = this.key !== void 0 ? planUpsert(existing, [input2], keyColumn)[0] : { action: "create", input: input2, key: "" };
45092
45115
  const deadline = this.type === "task" && this.deadline ? parseDeadline(this.deadline) : void 0;
45093
45116
  const ownerSpaceId = step.action === "create" ? await resolveOwnerSpace(caller, this.space) : "";
45094
- const ctx = { caller, entityId: entityId2, ownerSpaceId, keyColumn, type: this.type, ...deadline !== void 0 ? { deadline } : {} };
45117
+ const ctx = { caller, entityId: entityId2, ownerSpaceId, keyColumn, columns: view.columns, type: this.type, ...deadline !== void 0 ? { deadline } : {} };
45095
45118
  const progress = graphProgress(this, "list add", rowStages(ctx, step), { entityId: entityId2, ...step.action !== "create" ? { activityId: step.rowId } : {} });
45096
45119
  const rowId = await applyStep(ctx, step, progress);
45097
45120
  const result = stepResult(step, rowId);
@@ -45142,7 +45165,7 @@ var ListUpdate = class extends ProfileCommand {
45142
45165
  await progress.write("title", () => databaseWrite(() => caller.mutation(activitiesUpdateTitle3, args)), graphAck);
45143
45166
  }
45144
45167
  for (const [index, [key, value]] of Object.entries(attributes2).entries()) {
45145
- const args = cellArgs(row._id, key, value);
45168
+ const args = cellArgs(row._id, key, value, view.columns.find((column) => column.key === key));
45146
45169
  await progress.write(`cell:${index + 1}`, () => databaseWrite(() => caller.mutation(setAttributeValue, args)), (raw) => parseOperationResult("activities:setAttributeValue", databaseCellWriteContract.result, raw));
45147
45170
  }
45148
45171
  });
@@ -45199,7 +45222,7 @@ var ListImport = class extends ProfileCommand {
45199
45222
  throw new Error(`Line ${l.line}: ${errorMessage(exc)}`);
45200
45223
  }
45201
45224
  });
45202
- const existing = (await fetchAllRows(caller, entityId2)).map(toExisting);
45225
+ const existing = (await fetchRowsForKeys(caller, entityId2, inputs, this.key)).map(toExisting);
45203
45226
  const steps = planUpsert(existing, inputs, this.key);
45204
45227
  const needsSpace = steps.some((s) => s.action === "create");
45205
45228
  const ownerSpaceId = needsSpace ? await resolveOwnerSpace(caller, this.space) : "";
@@ -45209,7 +45232,7 @@ var ListImport = class extends ProfileCommand {
45209
45232
  if (this.dryRun) {
45210
45233
  steps.forEach((step, i) => results[i] = stepResult(step, step.action === "create" ? null : step.rowId));
45211
45234
  } else {
45212
- const ctx = { caller, entityId: entityId2, ownerSpaceId, keyColumn: this.key, type: "note" };
45235
+ const ctx = { caller, entityId: entityId2, ownerSpaceId, keyColumn: this.key, columns: view.columns, type: "note" };
45213
45236
  let done = 0;
45214
45237
  const writes = steps.map((step, index) => ({ step, index })).filter(({ step }) => step.action !== "unchanged");
45215
45238
  steps.forEach((step, i) => {
@@ -45355,6 +45378,7 @@ var ListShow = class extends ProfileCommand {
45355
45378
  const res = databaseListPage(await caller.query(listRows, parseDatabaseProtocolInput("database rows", databaseRowsArgs, {
45356
45379
  entityId: entityId2,
45357
45380
  ...this.view ? {} : { ignoreViewFilters: true },
45381
+ where: clauses,
45358
45382
  paginationOpts: { numItems, cursor: cursor3 }
45359
45383
  })));
45360
45384
  rows.push(...res.page);
@@ -45362,7 +45386,7 @@ var ListShow = class extends ProfileCommand {
45362
45386
  if (!this.all || nextCursor === null) break;
45363
45387
  cursor3 = nextCursor;
45364
45388
  }
45365
- const kept = rows.filter((row) => matchesWhere(row.attributes, clauses));
45389
+ const kept = rows;
45366
45390
  this.emitText(
45367
45391
  { data: { entityId: entityId2, rows: kept.map(rowJson), count: kept.length, nextCursor, isDone: nextCursor === null } },
45368
45392
  () => {