@giladbarnea/pi-simple-team 2.0.16 → 2.0.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.
Files changed (2) hide show
  1. package/index.ts +49 -3
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -124,6 +124,46 @@ function toolResult(payload: JsonRecord, viewDetails: JsonRecord = {}) {
124
124
  };
125
125
  }
126
126
 
127
+ const reminderSlugWords = {
128
+ adjectives: ["amber", "brisk", "calm", "clever", "dusty", "eager", "fuzzy", "gentle", "golden", "hollow", "jolly", "lively", "mellow", "misty", "nimble", "plucky", "quiet", "rapid", "rusty", "silver", "steady", "sunny", "swift", "witty"],
129
+ nouns: ["badger", "beacon", "cedar", "comet", "falcon", "fern", "harbor", "heron", "lantern", "maple", "meadow", "otter", "pebble", "pine", "quail", "raven", "river", "robin", "sparrow", "spruce", "thistle", "tulip", "walrus", "willow"],
130
+ } as const;
131
+
132
+ /** A random two-word label that ties a reminder's wake message to its arming. */
133
+ function reminderSlug(): string {
134
+ const pick = (words: readonly string[]): string => words[crypto.randomInt(words.length)]!;
135
+ return `${pick(reminderSlugWords.adjectives)}-${pick(reminderSlugWords.nouns)}`;
136
+ }
137
+
138
+ /**
139
+ * Formats a moment in the process time zone, with the time zone name the runtime's English locale data provides.
140
+ * @example humanTime(new Date("2026-11-07T08:47:00Z")) // with TZ=Asia/Jerusalem: "Nov 7, 2026, 10:47am GMT+2"
141
+ */
142
+ function humanTime(moment: Date): string {
143
+ const parts = Object.fromEntries(
144
+ new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", hour12: true, timeZoneName: "short" })
145
+ .formatToParts(moment)
146
+ .map((part) => [part.type, part.value]),
147
+ ) as Record<Intl.DateTimeFormatPartTypes, string>;
148
+ return `${parts.month} ${parts.day}, ${parts.year}, ${parts.hour}:${parts.minute}${parts.dayPeriod.toLowerCase()} ${parts.timeZoneName}`;
149
+ }
150
+
151
+ /**
152
+ * @example humanDuration(3665) // "1h, 1m and 5s"
153
+ * @example humanDuration(2700) // "45m"
154
+ * @example humanDuration(0) // "0s"
155
+ */
156
+ function humanDuration(totalSeconds: number): string {
157
+ const units = [
158
+ [Math.floor(totalSeconds / 3600), "h"],
159
+ [Math.floor((totalSeconds % 3600) / 60), "m"],
160
+ [totalSeconds % 60, "s"],
161
+ ] as const;
162
+ const parts = units.filter(([count]) => count > 0).map(([count, unit]) => `${count}${unit}`);
163
+ if (parts.length === 0) return "0s";
164
+ return parts.length === 1 ? parts[0]! : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
165
+ }
166
+
127
167
  /** @example teamIdentity({ name: "review", id: "session-review" }) // { teamName: "review", teamId: "session-review" } */
128
168
  function teamIdentity(team: { name: string; id?: string }): { teamName: string; teamId: string } {
129
169
  return { teamName: team.name, teamId: team.id ?? team.name };
@@ -1190,17 +1230,23 @@ export default function (pi: ExtensionAPI) {
1190
1230
  }, { additionalProperties: false }),
1191
1231
  async execute(_toolCallId, params) {
1192
1232
  const delayMilliseconds = params.delayMinutes * 60_000;
1193
- const scheduledAt = new Date(Date.now() + delayMilliseconds).toISOString();
1233
+ const delaySeconds = Math.round(delayMilliseconds / 1000);
1234
+ const armedAt = new Date();
1235
+ const wakeAt = new Date(armedAt.getTime() + delayMilliseconds);
1236
+ const slug = reminderSlug();
1194
1237
  const timer = setTimeout(() => {
1195
1238
  reminderTimers.delete(timer);
1196
1239
  pi.sendMessage(
1197
- { customType: "pi-simple-team-reminder", content: params.message, display: false },
1240
+ { customType: "pi-simple-team-reminder", content: `Reminder ${slug} wake up: it's ${humanTime(new Date())} now.\n\n${params.message}`, display: false },
1198
1241
  { deliverAs: "followUp", triggerTurn: true },
1199
1242
  );
1200
1243
  }, delayMilliseconds);
1201
1244
  reminderTimers.add(timer);
1202
1245
  timer.unref();
1203
- return toolResult({ scheduledAt, message: params.message });
1246
+ return {
1247
+ content: [{ type: "text" as const, text: `Armed reminder ${slug}: It's ${humanTime(armedAt)} now. Reminder set in ${delaySeconds} seconds (${humanDuration(delaySeconds)}) for ${humanTime(wakeAt)}.` }],
1248
+ details: { scheduledAt: wakeAt.toISOString(), message: params.message, slug },
1249
+ };
1204
1250
  },
1205
1251
  }),
1206
1252
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "2.0.16",
3
+ "version": "2.0.17",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",