chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerCreateBucketResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerCreateBucket')
|
||||
|
||||
export const createBucketTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerCreateBucketResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_create_bucket',
|
||||
name: 'Create Microsoft Planner Bucket',
|
||||
description: 'Create a new bucket in a Microsoft Planner plan',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The ID of the plan where the bucket will be created (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the bucket',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => 'https://graph.microsoft.com/v1.0/planner/buckets',
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
if (!params.planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
if (!params.name) {
|
||||
throw new Error('Bucket name is required')
|
||||
}
|
||||
|
||||
const body = {
|
||||
name: params.name,
|
||||
planId: params.planId,
|
||||
orderHint: ' !',
|
||||
}
|
||||
|
||||
logger.info('Creating bucket with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const bucket = await response.json()
|
||||
logger.info('Created bucket:', bucket)
|
||||
|
||||
const result: MicrosoftPlannerCreateBucketResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
bucket,
|
||||
metadata: {
|
||||
bucketId: bucket.id,
|
||||
planId: bucket.planId,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the bucket was created successfully' },
|
||||
bucket: { type: 'object', description: 'The created bucket object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including bucketId and planId',
|
||||
properties: {
|
||||
bucketId: { type: 'string', description: 'Created bucket ID' },
|
||||
planId: { type: 'string', description: 'Parent plan ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerCreatePlanResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerCreatePlan')
|
||||
|
||||
export const createPlanTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerCreatePlanResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_create_plan',
|
||||
name: 'Create Microsoft Planner Plan',
|
||||
description: 'Create a new Microsoft Planner plan owned by a Microsoft 365 group',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
groupId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The ID of the Microsoft 365 group that will own the plan (e.g., "ebf3b108-5234-4e22-b93d-656d7dae5874"). The current user must be a member of this group.',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The title of the plan',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => 'https://graph.microsoft.com/v1.0/planner/plans',
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
const groupId = params.groupId?.trim()
|
||||
if (!groupId) {
|
||||
throw new Error('Microsoft 365 group ID is required')
|
||||
}
|
||||
if (!params.title) {
|
||||
throw new Error('Plan title is required')
|
||||
}
|
||||
|
||||
const body = {
|
||||
container: {
|
||||
url: `https://graph.microsoft.com/v1.0/groups/${groupId}`,
|
||||
},
|
||||
title: params.title,
|
||||
}
|
||||
|
||||
logger.info('Creating plan with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const plan = await response.json()
|
||||
logger.info('Created plan:', plan)
|
||||
|
||||
const result: MicrosoftPlannerCreatePlanResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
plan,
|
||||
metadata: {
|
||||
planId: plan.id,
|
||||
groupId: plan.container?.containerId,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the plan was created successfully' },
|
||||
plan: { type: 'object', description: 'The created plan object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId and groupId',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Created plan ID' },
|
||||
groupId: { type: 'string', description: 'Owning Microsoft 365 group ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerCreateResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
PlannerTask,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerCreateTask')
|
||||
|
||||
export const createTaskTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerCreateResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_create_task',
|
||||
name: 'Create Microsoft Planner Task',
|
||||
description: 'Create a new task in Microsoft Planner',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The ID of the plan where the task will be created (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The title of the task (e.g., "Review quarterly report")',
|
||||
},
|
||||
dueDateTime: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The due date and time for the task in ISO 8601 format (e.g., "2025-03-15T17:00:00Z")',
|
||||
},
|
||||
startDateTime: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'The start date and time for the task in ISO 8601 format (e.g., "2025-03-10T09:00:00Z")',
|
||||
},
|
||||
priority: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The priority of the task (0-10, where 0 is urgent and 10 is low)',
|
||||
},
|
||||
percentComplete: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The percentage of task completion (0-100)',
|
||||
},
|
||||
assigneeUserId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The user ID to assign the task to (e.g., "e82f74c3-4d8a-4b5c-9f1e-2a6b8c9d0e3f")',
|
||||
},
|
||||
bucketId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The bucket ID to place the task in (e.g., "hsOf2dhOJkC6Fey9VjDg1JgAC9Rq")',
|
||||
},
|
||||
appliedCategories: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Comma-separated category labels to apply to the task, e.g. "category1,category3" (up to category1-category25, plan-defined color labels)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => 'https://graph.microsoft.com/v1.0/planner/tasks',
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
if (!params.planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
if (!params.title) {
|
||||
throw new Error('Task title is required')
|
||||
}
|
||||
|
||||
const body: PlannerTask = {
|
||||
planId: params.planId,
|
||||
title: params.title,
|
||||
}
|
||||
|
||||
if (params.bucketId !== undefined && params.bucketId !== null && params.bucketId !== '') {
|
||||
body.bucketId = params.bucketId
|
||||
}
|
||||
|
||||
if (
|
||||
params.dueDateTime !== undefined &&
|
||||
params.dueDateTime !== null &&
|
||||
params.dueDateTime !== ''
|
||||
) {
|
||||
body.dueDateTime = params.dueDateTime
|
||||
}
|
||||
|
||||
if (
|
||||
params.startDateTime !== undefined &&
|
||||
params.startDateTime !== null &&
|
||||
params.startDateTime !== ''
|
||||
) {
|
||||
body.startDateTime = params.startDateTime
|
||||
}
|
||||
|
||||
if (params.priority !== undefined && params.priority !== null) {
|
||||
body.priority = Number(params.priority)
|
||||
}
|
||||
|
||||
if (params.percentComplete !== undefined && params.percentComplete !== null) {
|
||||
body.percentComplete = Number(params.percentComplete)
|
||||
}
|
||||
|
||||
if (
|
||||
params.assigneeUserId !== undefined &&
|
||||
params.assigneeUserId !== null &&
|
||||
params.assigneeUserId !== ''
|
||||
) {
|
||||
body.assignments = {
|
||||
[params.assigneeUserId]: {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (params.appliedCategories?.trim()) {
|
||||
const categories = params.appliedCategories
|
||||
.split(',')
|
||||
.map((category) => category.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
if (categories.length > 0) {
|
||||
body.appliedCategories = Object.fromEntries(
|
||||
categories.map((category) =>
|
||||
category.startsWith('-') ? [category.slice(1), false] : [category, true]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
logger.info('Creating task with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const task = await response.json()
|
||||
logger.info('Created task:', task)
|
||||
|
||||
const result: MicrosoftPlannerCreateResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
task,
|
||||
metadata: {
|
||||
planId: task.planId,
|
||||
taskId: task.id,
|
||||
taskUrl: `https://graph.microsoft.com/v1.0/planner/tasks/${task.id}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the task was created successfully' },
|
||||
task: { type: 'object', description: 'The created task object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId, taskId, and taskUrl',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Parent plan ID' },
|
||||
taskId: { type: 'string', description: 'Created task ID' },
|
||||
taskUrl: { type: 'string', description: 'Microsoft Graph API URL for the task' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerDeleteBucketResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerDeleteBucket')
|
||||
|
||||
export const deleteBucketTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerDeleteBucketResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_delete_bucket',
|
||||
name: 'Delete Microsoft Planner Bucket',
|
||||
description: 'Delete a bucket from Microsoft Planner',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
bucketId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the bucket to delete (e.g., "hsOf2dhOJkC6Fey9VjDg1JgAC9Rq")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the bucket to delete (If-Match header)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const bucketId = params.bucketId?.trim()
|
||||
if (!bucketId) {
|
||||
throw new Error('Bucket ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/buckets/${bucketId}`
|
||||
},
|
||||
method: 'DELETE',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for delete operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
logger.info('Removed surrounding quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
logger.info('Cleaned escaped quotes from etag')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
logger.info('Bucket deleted successfully')
|
||||
|
||||
const result: MicrosoftPlannerDeleteBucketResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
deleted: true,
|
||||
metadata: {},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the bucket was deleted successfully' },
|
||||
deleted: { type: 'boolean', description: 'Confirmation of deletion' },
|
||||
metadata: { type: 'object', description: 'Additional metadata' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerDeletePlanResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerDeletePlan')
|
||||
|
||||
export const deletePlanTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerDeletePlanResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_delete_plan',
|
||||
name: 'Delete Microsoft Planner Plan',
|
||||
description: 'Delete a Microsoft Planner plan',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the plan to delete (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the plan to delete (If-Match header)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const planId = params.planId?.trim()
|
||||
if (!planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/plans/${planId}`
|
||||
},
|
||||
method: 'DELETE',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for delete operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
logger.info('Removed surrounding quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
logger.info('Cleaned escaped quotes from etag')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
logger.info('Plan deleted successfully')
|
||||
|
||||
const result: MicrosoftPlannerDeletePlanResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
deleted: true,
|
||||
metadata: {},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the plan was deleted successfully' },
|
||||
deleted: { type: 'boolean', description: 'Confirmation of deletion' },
|
||||
metadata: { type: 'object', description: 'Additional metadata' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerDeleteTaskResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerDeleteTask')
|
||||
|
||||
export const deleteTaskTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerDeleteTaskResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_delete_task',
|
||||
name: 'Delete Microsoft Planner Task',
|
||||
description: 'Delete a task from Microsoft Planner',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the task to delete (e.g., "pbT5K2OVkkO1M7r5bfsJ6JgAGD5m")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the task to delete (If-Match header)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const taskId = params.taskId?.trim()
|
||||
if (!taskId) {
|
||||
throw new Error('Task ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/tasks/${taskId}`
|
||||
},
|
||||
method: 'DELETE',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for delete operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
logger.info('Removed surrounding quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
logger.info('Cleaned escaped quotes from etag')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
logger.info('Task deleted successfully')
|
||||
|
||||
const result: MicrosoftPlannerDeleteTaskResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
deleted: true,
|
||||
metadata: {},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the task was deleted successfully' },
|
||||
deleted: { type: 'boolean', description: 'Confirmation of deletion' },
|
||||
metadata: { type: 'object', description: 'Additional metadata' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerGetPlanDetailsResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerGetPlanDetails')
|
||||
|
||||
export const getPlanDetailsTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerGetPlanDetailsResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_get_plan_details',
|
||||
name: 'Get Microsoft Planner Plan Details',
|
||||
description: 'Get detailed information about a plan including category descriptions and sharing',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the plan (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const planId = params.planId?.trim()
|
||||
if (!planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/plans/${planId}/details`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const planDetails = await response.json()
|
||||
logger.info('Plan details retrieved:', planDetails)
|
||||
|
||||
const etag = planDetails['@odata.etag'] || ''
|
||||
|
||||
const result: MicrosoftPlannerGetPlanDetailsResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
planDetails,
|
||||
etag,
|
||||
metadata: {
|
||||
planId: planDetails.id,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'boolean',
|
||||
description: 'Whether the plan details were retrieved successfully',
|
||||
},
|
||||
planDetails: {
|
||||
type: 'object',
|
||||
description: 'The plan details including categoryDescriptions and sharedWith',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
description: 'The ETag value for this plan details resource',
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Plan ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerGetTaskDetailsResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerGetTaskDetails')
|
||||
|
||||
export const getTaskDetailsTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerGetTaskDetailsResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_get_task_details',
|
||||
name: 'Get Microsoft Planner Task Details',
|
||||
description: 'Get detailed information about a task including checklist and references',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the task (e.g., "pbT5K2OVkkO1M7r5bfsJ6JgAGD5m")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const taskId = params.taskId?.trim()
|
||||
if (!taskId) {
|
||||
throw new Error('Task ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/tasks/${taskId}/details`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const taskDetails = await response.json()
|
||||
logger.info('Task details retrieved:', taskDetails)
|
||||
|
||||
const etag = taskDetails['@odata.etag'] || ''
|
||||
|
||||
const result: MicrosoftPlannerGetTaskDetailsResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
taskDetails,
|
||||
etag,
|
||||
metadata: {
|
||||
taskId: taskDetails.id,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'boolean',
|
||||
description: 'Whether the task details were retrieved successfully',
|
||||
},
|
||||
taskDetails: {
|
||||
type: 'object',
|
||||
description: 'The task details including description, checklist, and references',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
description: 'The ETag value for this task details - use this for update operations',
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including taskId',
|
||||
properties: {
|
||||
taskId: { type: 'string', description: 'Task ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { createBucketTool } from '@/tools/microsoft_planner/create_bucket'
|
||||
import { createPlanTool } from '@/tools/microsoft_planner/create_plan'
|
||||
import { createTaskTool } from '@/tools/microsoft_planner/create_task'
|
||||
import { deleteBucketTool } from '@/tools/microsoft_planner/delete_bucket'
|
||||
import { deletePlanTool } from '@/tools/microsoft_planner/delete_plan'
|
||||
import { deleteTaskTool } from '@/tools/microsoft_planner/delete_task'
|
||||
import { getPlanDetailsTool } from '@/tools/microsoft_planner/get_plan_details'
|
||||
import { getTaskDetailsTool } from '@/tools/microsoft_planner/get_task_details'
|
||||
import { listBucketsTool } from '@/tools/microsoft_planner/list_buckets'
|
||||
import { listPlansTool } from '@/tools/microsoft_planner/list_plans'
|
||||
import { readBucketTool } from '@/tools/microsoft_planner/read_bucket'
|
||||
import { readPlanTool } from '@/tools/microsoft_planner/read_plan'
|
||||
import { readTaskTool } from '@/tools/microsoft_planner/read_task'
|
||||
import { updateBucketTool } from '@/tools/microsoft_planner/update_bucket'
|
||||
import { updatePlanTool } from '@/tools/microsoft_planner/update_plan'
|
||||
import { updatePlanDetailsTool } from '@/tools/microsoft_planner/update_plan_details'
|
||||
import { updateTaskTool } from '@/tools/microsoft_planner/update_task'
|
||||
import { updateTaskDetailsTool } from '@/tools/microsoft_planner/update_task_details'
|
||||
|
||||
export const microsoftPlannerCreateTaskTool = createTaskTool
|
||||
export const microsoftPlannerReadTaskTool = readTaskTool
|
||||
export const microsoftPlannerUpdateTaskTool = updateTaskTool
|
||||
export const microsoftPlannerDeleteTaskTool = deleteTaskTool
|
||||
export const microsoftPlannerListPlansTool = listPlansTool
|
||||
export const microsoftPlannerReadPlanTool = readPlanTool
|
||||
export const microsoftPlannerCreatePlanTool = createPlanTool
|
||||
export const microsoftPlannerUpdatePlanTool = updatePlanTool
|
||||
export const microsoftPlannerGetPlanDetailsTool = getPlanDetailsTool
|
||||
export const microsoftPlannerUpdatePlanDetailsTool = updatePlanDetailsTool
|
||||
export const microsoftPlannerDeletePlanTool = deletePlanTool
|
||||
export const microsoftPlannerListBucketsTool = listBucketsTool
|
||||
export const microsoftPlannerReadBucketTool = readBucketTool
|
||||
export const microsoftPlannerCreateBucketTool = createBucketTool
|
||||
export const microsoftPlannerUpdateBucketTool = updateBucketTool
|
||||
export const microsoftPlannerDeleteBucketTool = deleteBucketTool
|
||||
export const microsoftPlannerGetTaskDetailsTool = getTaskDetailsTool
|
||||
export const microsoftPlannerUpdateTaskDetailsTool = updateTaskDetailsTool
|
||||
@@ -0,0 +1,91 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerListBucketsResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerListBuckets')
|
||||
|
||||
export const listBucketsTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerListBucketsResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_list_buckets',
|
||||
name: 'List Microsoft Planner Buckets',
|
||||
description: 'List all buckets in a Microsoft Planner plan',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the plan (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const planId = params.planId?.trim()
|
||||
if (!planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/plans/${planId}/buckets`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
logger.info('List buckets response:', data)
|
||||
|
||||
const buckets = data.value || []
|
||||
|
||||
const result: MicrosoftPlannerListBucketsResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
buckets,
|
||||
metadata: {
|
||||
planId: buckets.length > 0 ? buckets[0].planId : null,
|
||||
count: buckets.length,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether buckets were retrieved successfully' },
|
||||
buckets: { type: 'array', description: 'Array of bucket objects' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId and count',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Plan ID', optional: true },
|
||||
count: { type: 'number', description: 'Number of buckets returned' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerListPlansResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerListPlans')
|
||||
|
||||
export const listPlansTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerListPlansResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_list_plans',
|
||||
name: 'List Microsoft Planner Plans',
|
||||
description: 'List all plans shared with the current user',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => {
|
||||
return 'https://graph.microsoft.com/v1.0/me/planner/plans'
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
logger.info('List plans response:', data)
|
||||
|
||||
const plans = data.value || []
|
||||
|
||||
const result: MicrosoftPlannerListPlansResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
plans,
|
||||
metadata: {
|
||||
count: plans.length,
|
||||
userId: 'me',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether plans were retrieved successfully' },
|
||||
plans: { type: 'array', description: 'Array of plan objects shared with the current user' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including userId and count',
|
||||
properties: {
|
||||
count: { type: 'number', description: 'Number of plans returned' },
|
||||
userId: { type: 'string', description: 'User ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerReadBucketResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerReadBucket')
|
||||
|
||||
export const readBucketTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerReadBucketResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_read_bucket',
|
||||
name: 'Read Microsoft Planner Bucket',
|
||||
description: 'Get details of a specific bucket',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
bucketId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the bucket to retrieve (e.g., "hsOf2dhOJkC6Fey9VjDg1JgAC9Rq")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const bucketId = params.bucketId?.trim()
|
||||
if (!bucketId) {
|
||||
throw new Error('Bucket ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/buckets/${bucketId}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const bucket = await response.json()
|
||||
logger.info('Read bucket response:', bucket)
|
||||
|
||||
const result: MicrosoftPlannerReadBucketResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
bucket,
|
||||
metadata: {
|
||||
bucketId: bucket.id,
|
||||
planId: bucket.planId,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the bucket was retrieved successfully' },
|
||||
bucket: { type: 'object', description: 'The bucket object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including bucketId and planId',
|
||||
properties: {
|
||||
bucketId: { type: 'string', description: 'Bucket ID' },
|
||||
planId: { type: 'string', description: 'Parent plan ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import type {
|
||||
MicrosoftPlannerReadPlanResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerReadPlan')
|
||||
|
||||
export const readPlanTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerReadPlanResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_read_plan',
|
||||
name: 'Read Microsoft Planner Plan',
|
||||
description: 'Get details of a specific Microsoft Planner plan',
|
||||
version: '1.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the plan to retrieve (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const planId = params.planId?.trim()
|
||||
if (!planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/plans/${planId}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const plan = await response.json()
|
||||
logger.info('Read plan response:', plan)
|
||||
|
||||
const result: MicrosoftPlannerReadPlanResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
plan,
|
||||
metadata: {
|
||||
planId: plan.id,
|
||||
planUrl: `https://graph.microsoft.com/v1.0/planner/plans/${plan.id}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the plan was retrieved successfully' },
|
||||
plan: { type: 'object', description: 'The plan object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId and planUrl',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Plan ID' },
|
||||
planUrl: { type: 'string', description: 'Microsoft Graph API URL for the plan' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerReadResponse,
|
||||
MicrosoftPlannerToolParams,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerReadTask')
|
||||
|
||||
export const readTaskTool: ToolConfig<MicrosoftPlannerToolParams, MicrosoftPlannerReadResponse> = {
|
||||
id: 'microsoft_planner_read_task',
|
||||
name: 'Read Microsoft Planner Tasks',
|
||||
description:
|
||||
'Read tasks from Microsoft Planner - get all user tasks or all tasks from a specific plan',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The ID of the plan to get tasks from, if not provided gets all user tasks (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the task to get (e.g., "pbT5K2OVkkO1M7r5bfsJ6JgAGD5m")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
let finalUrl: string
|
||||
|
||||
// If taskId is provided, get specific task
|
||||
if (params.taskId) {
|
||||
// Validate and clean task ID
|
||||
const cleanTaskId = params.taskId.trim()
|
||||
if (!cleanTaskId) {
|
||||
throw new Error('Task ID cannot be empty')
|
||||
}
|
||||
|
||||
// Log the task ID for debugging
|
||||
logger.info('Fetching task with ID:', cleanTaskId)
|
||||
logger.info('Task ID length:', cleanTaskId.length)
|
||||
logger.info('Task ID has special chars:', /[^a-zA-Z0-9_-]/.test(cleanTaskId))
|
||||
|
||||
finalUrl = `https://graph.microsoft.com/v1.0/planner/tasks/${cleanTaskId}`
|
||||
}
|
||||
// Else if planId is provided, get tasks from plan
|
||||
else if (params.planId) {
|
||||
const cleanPlanId = params.planId.trim()
|
||||
if (!cleanPlanId) {
|
||||
throw new Error('Plan ID cannot be empty')
|
||||
}
|
||||
logger.info('Fetching tasks for plan:', cleanPlanId)
|
||||
finalUrl = `https://graph.microsoft.com/v1.0/planner/plans/${cleanPlanId}/tasks`
|
||||
}
|
||||
// Else get all user tasks
|
||||
else {
|
||||
logger.info('Fetching all user tasks')
|
||||
finalUrl = 'https://graph.microsoft.com/v1.0/me/planner/tasks'
|
||||
}
|
||||
|
||||
logger.info('Microsoft Planner URL:', finalUrl)
|
||||
return finalUrl
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
logger.info('Access token present:', !!params.accessToken)
|
||||
logger.info('Access token length:', params.accessToken.length)
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
logger.info('Raw response data:', data)
|
||||
|
||||
const rawTasks = data.value ? data.value : Array.isArray(data) ? data : [data]
|
||||
|
||||
const tasks = rawTasks.map((task: any) => {
|
||||
let etagValue = task['@odata.etag'] ?? null
|
||||
logger.info('ETag value extracted (raw):', {
|
||||
raw: etagValue,
|
||||
type: typeof etagValue,
|
||||
length: etagValue?.length,
|
||||
})
|
||||
|
||||
if (etagValue && typeof etagValue === 'string') {
|
||||
if (etagValue.includes('\\"')) {
|
||||
etagValue = etagValue.replace(/\\"/g, '"')
|
||||
logger.info('Unescaped etag quotes:', { cleaned: etagValue })
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: task.id,
|
||||
title: task.title,
|
||||
planId: task.planId,
|
||||
bucketId: task.bucketId ?? null,
|
||||
percentComplete: task.percentComplete,
|
||||
priority: task.priority,
|
||||
dueDateTime: task.dueDateTime ?? null,
|
||||
createdDateTime: task.createdDateTime,
|
||||
completedDateTime: task.completedDateTime ?? null,
|
||||
hasDescription: task.hasDescription,
|
||||
assignments: task.assignments ? Object.keys(task.assignments) : [],
|
||||
etag: etagValue,
|
||||
}
|
||||
})
|
||||
|
||||
const result: MicrosoftPlannerReadResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
tasks,
|
||||
metadata: {
|
||||
planId: tasks.length > 0 ? tasks[0].planId : null,
|
||||
userId: data.value ? null : 'me',
|
||||
planUrl:
|
||||
tasks.length > 0
|
||||
? `https://graph.microsoft.com/v1.0/planner/plans/${tasks[0].planId}`
|
||||
: null,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logger.info('Successfully transformed response with', tasks.length, 'tasks')
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether tasks were retrieved successfully' },
|
||||
tasks: { type: 'array', description: 'Array of task objects with filtered properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId, userId, and planUrl',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Plan ID', optional: true },
|
||||
userId: { type: 'string', description: 'User ID', optional: true },
|
||||
planUrl: {
|
||||
type: 'string',
|
||||
description: 'Microsoft Graph API URL for the plan',
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
interface PlannerIdentitySet {
|
||||
user?: {
|
||||
displayName?: string
|
||||
id?: string
|
||||
}
|
||||
application?: {
|
||||
displayName?: string
|
||||
id?: string
|
||||
}
|
||||
}
|
||||
|
||||
interface PlannerAssignment {
|
||||
'@odata.type': string
|
||||
assignedDateTime?: string
|
||||
orderHint?: string
|
||||
assignedBy?: PlannerIdentitySet
|
||||
}
|
||||
|
||||
interface PlannerReference {
|
||||
alias?: string
|
||||
lastModifiedBy?: PlannerIdentitySet
|
||||
lastModifiedDateTime?: string
|
||||
previewPriority?: string
|
||||
type?: string
|
||||
}
|
||||
|
||||
interface PlannerChecklistItem {
|
||||
'@odata.type': string
|
||||
isChecked?: boolean
|
||||
title?: string
|
||||
orderHint?: string
|
||||
lastModifiedBy?: PlannerIdentitySet
|
||||
lastModifiedDateTime?: string
|
||||
}
|
||||
|
||||
interface PlannerContainer {
|
||||
containerId?: string
|
||||
type?: string
|
||||
url?: string
|
||||
}
|
||||
|
||||
interface PlannerAppliedCategories {
|
||||
[category: string]: boolean
|
||||
}
|
||||
|
||||
export interface PlannerTask {
|
||||
id?: string
|
||||
planId: string
|
||||
title: string
|
||||
orderHint?: string
|
||||
assigneePriority?: string
|
||||
percentComplete?: number
|
||||
startDateTime?: string
|
||||
createdDateTime?: string
|
||||
dueDateTime?: string
|
||||
hasDescription?: boolean
|
||||
previewType?: string
|
||||
completedDateTime?: string
|
||||
completedBy?: PlannerIdentitySet
|
||||
referenceCount?: number
|
||||
checklistItemCount?: number
|
||||
activeChecklistItemCount?: number
|
||||
conversationThreadId?: string
|
||||
priority?: number
|
||||
assignments?: Record<string, PlannerAssignment>
|
||||
appliedCategories?: PlannerAppliedCategories
|
||||
bucketId?: string
|
||||
details?: {
|
||||
description?: string
|
||||
references?: Record<string, PlannerReference>
|
||||
checklist?: Record<string, PlannerChecklistItem>
|
||||
}
|
||||
}
|
||||
|
||||
export interface PlannerBucket {
|
||||
id: string
|
||||
name: string
|
||||
planId: string
|
||||
orderHint?: string
|
||||
'@odata.etag'?: string
|
||||
}
|
||||
|
||||
export interface PlannerPlan {
|
||||
id: string
|
||||
title: string
|
||||
owner?: string
|
||||
createdDateTime?: string
|
||||
container?: PlannerContainer
|
||||
'@odata.etag'?: string
|
||||
}
|
||||
|
||||
export interface PlannerPlanDetails {
|
||||
id: string
|
||||
categoryDescriptions?: Record<string, string | null>
|
||||
sharedWith?: Record<string, boolean>
|
||||
'@odata.etag'?: string
|
||||
}
|
||||
|
||||
export interface PlannerTaskDetails {
|
||||
id: string
|
||||
description?: string
|
||||
previewType?: string
|
||||
references?: Record<string, PlannerReference>
|
||||
checklist?: Record<string, PlannerChecklistItem>
|
||||
'@odata.etag'?: string
|
||||
}
|
||||
|
||||
interface MicrosoftPlannerMetadata {
|
||||
planId?: string
|
||||
taskId?: string
|
||||
userId?: string | null
|
||||
planUrl?: string | null
|
||||
taskUrl?: string
|
||||
bucketId?: string
|
||||
groupId?: string
|
||||
count?: number
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerReadResponse extends ToolResponse {
|
||||
output: {
|
||||
tasks?: PlannerTask[]
|
||||
task?: PlannerTask
|
||||
plan?: PlannerPlan
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerCreateResponse extends ToolResponse {
|
||||
output: {
|
||||
task: PlannerTask
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerUpdateTaskResponse extends ToolResponse {
|
||||
output: {
|
||||
message: string
|
||||
task: PlannerTask
|
||||
taskId: string
|
||||
etag: string
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerDeleteTaskResponse extends ToolResponse {
|
||||
output: {
|
||||
deleted: boolean
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerListPlansResponse extends ToolResponse {
|
||||
output: {
|
||||
plans: PlannerPlan[]
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerReadPlanResponse extends ToolResponse {
|
||||
output: {
|
||||
plan: PlannerPlan
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerCreatePlanResponse extends ToolResponse {
|
||||
output: {
|
||||
plan: PlannerPlan
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerDeletePlanResponse extends ToolResponse {
|
||||
output: {
|
||||
deleted: boolean
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerGetPlanDetailsResponse extends ToolResponse {
|
||||
output: {
|
||||
planDetails: PlannerPlanDetails
|
||||
etag: string
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerListBucketsResponse extends ToolResponse {
|
||||
output: {
|
||||
buckets: PlannerBucket[]
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerReadBucketResponse extends ToolResponse {
|
||||
output: {
|
||||
bucket: PlannerBucket
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerCreateBucketResponse extends ToolResponse {
|
||||
output: {
|
||||
bucket: PlannerBucket
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerUpdateBucketResponse extends ToolResponse {
|
||||
output: {
|
||||
bucket: PlannerBucket
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerDeleteBucketResponse extends ToolResponse {
|
||||
output: {
|
||||
deleted: boolean
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerGetTaskDetailsResponse extends ToolResponse {
|
||||
output: {
|
||||
taskDetails: PlannerTaskDetails
|
||||
etag: string
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerUpdateTaskDetailsResponse extends ToolResponse {
|
||||
output: {
|
||||
taskDetails: PlannerTaskDetails
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerUpdatePlanResponse extends ToolResponse {
|
||||
output: {
|
||||
plan: PlannerPlan
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerUpdatePlanDetailsResponse extends ToolResponse {
|
||||
output: {
|
||||
planDetails: PlannerPlanDetails
|
||||
metadata: MicrosoftPlannerMetadata
|
||||
}
|
||||
}
|
||||
|
||||
export interface MicrosoftPlannerToolParams {
|
||||
accessToken: string
|
||||
planId?: string
|
||||
taskId?: string
|
||||
title?: string
|
||||
description?: string
|
||||
dueDateTime?: string
|
||||
startDateTime?: string
|
||||
assigneeUserId?: string
|
||||
bucketId?: string
|
||||
priority?: number
|
||||
percentComplete?: number
|
||||
groupId?: string
|
||||
name?: string
|
||||
etag?: string
|
||||
checklist?: Record<string, any>
|
||||
references?: Record<string, any>
|
||||
previewType?: string
|
||||
appliedCategories?: string
|
||||
categoryDescriptions?: Record<string, any>
|
||||
sharedWith?: Record<string, any>
|
||||
}
|
||||
|
||||
export type MicrosoftPlannerResponse =
|
||||
| MicrosoftPlannerReadResponse
|
||||
| MicrosoftPlannerCreateResponse
|
||||
| MicrosoftPlannerUpdateTaskResponse
|
||||
| MicrosoftPlannerDeleteTaskResponse
|
||||
| MicrosoftPlannerListPlansResponse
|
||||
| MicrosoftPlannerReadPlanResponse
|
||||
| MicrosoftPlannerCreatePlanResponse
|
||||
| MicrosoftPlannerDeletePlanResponse
|
||||
| MicrosoftPlannerGetPlanDetailsResponse
|
||||
| MicrosoftPlannerListBucketsResponse
|
||||
| MicrosoftPlannerReadBucketResponse
|
||||
| MicrosoftPlannerCreateBucketResponse
|
||||
| MicrosoftPlannerUpdateBucketResponse
|
||||
| MicrosoftPlannerDeleteBucketResponse
|
||||
| MicrosoftPlannerGetTaskDetailsResponse
|
||||
| MicrosoftPlannerUpdateTaskDetailsResponse
|
||||
| MicrosoftPlannerUpdatePlanResponse
|
||||
| MicrosoftPlannerUpdatePlanDetailsResponse
|
||||
@@ -0,0 +1,152 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdateBucketResponse,
|
||||
PlannerBucket,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerUpdateBucket')
|
||||
|
||||
export const updateBucketTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdateBucketResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_update_bucket',
|
||||
name: 'Update Microsoft Planner Bucket',
|
||||
description: 'Update a bucket in Microsoft Planner',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
bucketId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the bucket to update (e.g., "hsOf2dhOJkC6Fey9VjDg1JgAC9Rq")',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The new name of the bucket',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the bucket to update (If-Match header)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const bucketId = params.bucketId?.trim()
|
||||
if (!bucketId) {
|
||||
throw new Error('Bucket ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/buckets/${bucketId}`
|
||||
},
|
||||
method: 'PATCH',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for update operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
logger.info('Removed surrounding quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
logger.info('Cleaned escaped quotes from etag')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
const body: Record<string, any> = {}
|
||||
|
||||
if (params.name) {
|
||||
body.name = params.name
|
||||
}
|
||||
|
||||
if (Object.keys(body).length === 0) {
|
||||
throw new Error('At least one field must be provided to update')
|
||||
}
|
||||
|
||||
logger.info('Updating bucket with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response, params?: MicrosoftPlannerToolParams) => {
|
||||
// Prefer: return=representation requests a body, but the service may still return
|
||||
// 204 No Content for some tenants/requests
|
||||
const text = await response.text()
|
||||
if (!text || text.trim() === '') {
|
||||
logger.info('Update successful but no response body returned (204 No Content)')
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
bucket: {} as PlannerBucket,
|
||||
metadata: {
|
||||
bucketId: params?.bucketId?.trim(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const bucket = JSON.parse(text)
|
||||
logger.info('Updated bucket:', bucket)
|
||||
|
||||
const result: MicrosoftPlannerUpdateBucketResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
bucket,
|
||||
metadata: {
|
||||
bucketId: bucket.id,
|
||||
planId: bucket.planId,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the bucket was updated successfully' },
|
||||
bucket: { type: 'object', description: 'The updated bucket object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including bucketId and planId',
|
||||
properties: {
|
||||
bucketId: { type: 'string', description: 'Updated bucket ID' },
|
||||
planId: { type: 'string', description: 'Parent plan ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdatePlanResponse,
|
||||
PlannerPlan,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerUpdatePlan')
|
||||
|
||||
export const updatePlanTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdatePlanResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_update_plan',
|
||||
name: 'Update Microsoft Planner Plan',
|
||||
description: 'Rename a Microsoft Planner plan',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the plan to update (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the plan to update (If-Match header)',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The new title of the plan',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const planId = params.planId?.trim()
|
||||
if (!planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/plans/${planId}`
|
||||
},
|
||||
method: 'PATCH',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for update operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
if (!params.title?.trim()) {
|
||||
throw new Error('Plan title is required')
|
||||
}
|
||||
|
||||
const body = { title: params.title.trim() }
|
||||
|
||||
logger.info('Updating plan with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response, params?: MicrosoftPlannerToolParams) => {
|
||||
// Prefer: return=representation requests a body, but the service may still return
|
||||
// 204 No Content for some tenants/requests
|
||||
const text = await response.text()
|
||||
if (!text || text.trim() === '') {
|
||||
logger.info('Update successful but no response body returned (204 No Content)')
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
plan: {} as PlannerPlan,
|
||||
metadata: {
|
||||
planId: params?.planId?.trim(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const plan = JSON.parse(text)
|
||||
logger.info('Updated plan:', plan)
|
||||
|
||||
const result: MicrosoftPlannerUpdatePlanResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
plan,
|
||||
metadata: {
|
||||
planId: plan.id,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the plan was updated successfully' },
|
||||
plan: { type: 'object', description: 'The updated plan object with all properties' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Updated plan ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdatePlanDetailsResponse,
|
||||
PlannerPlanDetails,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerUpdatePlanDetails')
|
||||
|
||||
export const updatePlanDetailsTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdatePlanDetailsResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_update_plan_details',
|
||||
name: 'Update Microsoft Planner Plan Details',
|
||||
description:
|
||||
"Update a plan's category (color label) descriptions and shared-with user list in Microsoft Planner",
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
planId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the plan (e.g., "xqQg5FS2LkCe54tAMV_v2ZgADW2J")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the plan details to update (If-Match header)',
|
||||
},
|
||||
categoryDescriptions: {
|
||||
type: 'object',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'Category label names as a JSON object, e.g. {"category1": "Blocked", "category2": "At Risk"}. Set a value to null to clear a label.',
|
||||
},
|
||||
sharedWith: {
|
||||
type: 'object',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'User IDs to share the plan with as a JSON object, e.g. {"<user-id>": true}. Set a value to false to unshare.',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const planId = params.planId?.trim()
|
||||
if (!planId) {
|
||||
throw new Error('Plan ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/plans/${planId}/details`
|
||||
},
|
||||
method: 'PATCH',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for update operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
const body: Record<string, any> = {}
|
||||
|
||||
if (params.categoryDescriptions) {
|
||||
try {
|
||||
body.categoryDescriptions =
|
||||
typeof params.categoryDescriptions === 'string'
|
||||
? JSON.parse(params.categoryDescriptions)
|
||||
: params.categoryDescriptions
|
||||
} catch {
|
||||
throw new Error('categoryDescriptions must be valid JSON')
|
||||
}
|
||||
}
|
||||
|
||||
if (params.sharedWith) {
|
||||
try {
|
||||
body.sharedWith =
|
||||
typeof params.sharedWith === 'string'
|
||||
? JSON.parse(params.sharedWith)
|
||||
: params.sharedWith
|
||||
} catch {
|
||||
throw new Error('sharedWith must be valid JSON')
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(body).length === 0) {
|
||||
throw new Error('At least one field must be provided to update')
|
||||
}
|
||||
|
||||
logger.info('Updating plan details with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response, params?: MicrosoftPlannerToolParams) => {
|
||||
// Prefer: return=representation requests a body, but the service may still return
|
||||
// 204 No Content for some tenants/requests
|
||||
const text = await response.text()
|
||||
if (!text || text.trim() === '') {
|
||||
logger.info('Update successful but no response body returned (204 No Content)')
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
planDetails: {} as PlannerPlanDetails,
|
||||
metadata: {
|
||||
planId: params?.planId?.trim(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const planDetails = JSON.parse(text)
|
||||
logger.info('Updated plan details:', planDetails)
|
||||
|
||||
const result: MicrosoftPlannerUpdatePlanDetailsResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
planDetails,
|
||||
metadata: {
|
||||
planId: planDetails.id,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'boolean',
|
||||
description: 'Whether the plan details were updated successfully',
|
||||
},
|
||||
planDetails: {
|
||||
type: 'object',
|
||||
description: 'The updated plan details object with categoryDescriptions and sharedWith',
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including planId',
|
||||
properties: {
|
||||
planId: { type: 'string', description: 'Plan ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdateTaskResponse,
|
||||
PlannerTask,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerUpdateTask')
|
||||
|
||||
export const updateTaskTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdateTaskResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_update_task',
|
||||
name: 'Update Microsoft Planner Task',
|
||||
description: 'Update a task in Microsoft Planner',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the task to update (e.g., "pbT5K2OVkkO1M7r5bfsJ6JgAGD5m")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the task to update (If-Match header)',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The new title of the task (e.g., "Review quarterly report")',
|
||||
},
|
||||
bucketId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The bucket ID to move the task to (e.g., "hsOf2dhOJkC6Fey9VjDg1JgAC9Rq")',
|
||||
},
|
||||
dueDateTime: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The due date and time for the task in ISO 8601 format (e.g., "2025-03-15T17:00:00Z")',
|
||||
},
|
||||
startDateTime: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The start date and time for the task (ISO 8601 format)',
|
||||
},
|
||||
percentComplete: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The percentage of task completion (0-100)',
|
||||
},
|
||||
priority: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The priority of the task (0-10)',
|
||||
},
|
||||
assigneeUserId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'The user ID to assign the task to (e.g., "e82f74c3-4d8a-4b5c-9f1e-2a6b8c9d0e3f")',
|
||||
},
|
||||
appliedCategories: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Comma-separated category labels to apply to the task, e.g. "category1,category3" (up to category1-category25, plan-defined color labels)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const taskId = params.taskId?.trim()
|
||||
if (!taskId) {
|
||||
throw new Error('Task ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/tasks/${taskId}`
|
||||
},
|
||||
method: 'PATCH',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for update operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
logger.info('ETag value received (raw):', { etag: params.etag, length: params.etag.length })
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
logger.info('Removed surrounding quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
logger.info('Cleaned escaped quotes from etag:', {
|
||||
original: params.etag,
|
||||
cleaned: cleanedEtag,
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
const body: Partial<PlannerTask> = {}
|
||||
|
||||
if (params.title !== undefined && params.title !== null && params.title !== '') {
|
||||
body.title = params.title
|
||||
}
|
||||
|
||||
if (params.bucketId !== undefined && params.bucketId !== null && params.bucketId !== '') {
|
||||
body.bucketId = params.bucketId
|
||||
}
|
||||
|
||||
if (
|
||||
params.dueDateTime !== undefined &&
|
||||
params.dueDateTime !== null &&
|
||||
params.dueDateTime !== ''
|
||||
) {
|
||||
body.dueDateTime = params.dueDateTime
|
||||
}
|
||||
|
||||
if (
|
||||
params.startDateTime !== undefined &&
|
||||
params.startDateTime !== null &&
|
||||
params.startDateTime !== ''
|
||||
) {
|
||||
body.startDateTime = params.startDateTime
|
||||
}
|
||||
|
||||
if (params.percentComplete !== undefined && params.percentComplete !== null) {
|
||||
body.percentComplete = params.percentComplete
|
||||
}
|
||||
|
||||
if (params.priority !== undefined && params.priority !== null) {
|
||||
body.priority = Number(params.priority)
|
||||
}
|
||||
|
||||
if (
|
||||
params.assigneeUserId !== undefined &&
|
||||
params.assigneeUserId !== null &&
|
||||
params.assigneeUserId !== ''
|
||||
) {
|
||||
body.assignments = {
|
||||
[params.assigneeUserId]: {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (params.appliedCategories?.trim()) {
|
||||
const categories = params.appliedCategories
|
||||
.split(',')
|
||||
.map((category) => category.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
if (categories.length > 0) {
|
||||
body.appliedCategories = Object.fromEntries(
|
||||
categories.map((category) =>
|
||||
category.startsWith('-') ? [category.slice(1), false] : [category, true]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(body).length === 0) {
|
||||
throw new Error('At least one field must be provided to update')
|
||||
}
|
||||
|
||||
logger.info('Updating task with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response, params?: MicrosoftPlannerToolParams) => {
|
||||
// Check if response has content before parsing (Prefer: return=representation requests a
|
||||
// body, but the service may still return 204 No Content for some tenants/requests)
|
||||
const text = await response.text()
|
||||
if (!text || text.trim() === '') {
|
||||
logger.info('Update successful but no response body returned (204 No Content)')
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
// Graph returned no body, so the etag sent in this request is now stale (the
|
||||
// update changed it) and the actual new value is unknown. Returning it here would
|
||||
// let a chained update silently reuse a stale If-Match and fail with 412 — leave
|
||||
// it empty so callers re-fetch the task before their next update.
|
||||
message: 'Task updated successfully (re-fetch the task to get its current etag)',
|
||||
task: {} as PlannerTask,
|
||||
taskId: params?.taskId?.trim() || '',
|
||||
etag: '',
|
||||
metadata: {
|
||||
taskId: params?.taskId?.trim(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const task = JSON.parse(text)
|
||||
logger.info('Updated task:', task)
|
||||
|
||||
// Extract and clean the new etag for subsequent operations
|
||||
let newEtag = task['@odata.etag'] ?? null
|
||||
if (newEtag && typeof newEtag === 'string' && newEtag.includes('\\"')) {
|
||||
newEtag = newEtag.replace(/\\"/g, '"')
|
||||
}
|
||||
|
||||
const result: MicrosoftPlannerUpdateTaskResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
message: 'Task updated successfully',
|
||||
task,
|
||||
taskId: task.id,
|
||||
etag: newEtag,
|
||||
metadata: {
|
||||
taskId: task.id,
|
||||
planId: task.planId,
|
||||
taskUrl: `https://graph.microsoft.com/v1.0/planner/tasks/${task.id}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the task was updated successfully' },
|
||||
message: { type: 'string', description: 'Success message when task is updated' },
|
||||
task: { type: 'object', description: 'The updated task object with all properties' },
|
||||
taskId: { type: 'string', description: 'ID of the updated task' },
|
||||
etag: {
|
||||
type: 'string',
|
||||
description: 'New ETag after update - use this for subsequent operations',
|
||||
optional: true,
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including taskId, planId, and taskUrl',
|
||||
properties: {
|
||||
taskId: { type: 'string', description: 'Updated task ID' },
|
||||
planId: { type: 'string', description: 'Parent plan ID' },
|
||||
taskUrl: { type: 'string', description: 'Microsoft Graph API URL for the task' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ErrorExtractorId } from '@/tools/error-extractors'
|
||||
import type {
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdateTaskDetailsResponse,
|
||||
PlannerTaskDetails,
|
||||
} from '@/tools/microsoft_planner/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('MicrosoftPlannerUpdateTaskDetails')
|
||||
|
||||
export const updateTaskDetailsTool: ToolConfig<
|
||||
MicrosoftPlannerToolParams,
|
||||
MicrosoftPlannerUpdateTaskDetailsResponse
|
||||
> = {
|
||||
id: 'microsoft_planner_update_task_details',
|
||||
name: 'Update Microsoft Planner Task Details',
|
||||
description:
|
||||
'Update task details including description, checklist items, and references in Microsoft Planner',
|
||||
version: '1.0',
|
||||
errorExtractor: ErrorExtractorId.MICROSOFT_GRAPH_ERRORS,
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'microsoft-planner',
|
||||
},
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Microsoft Planner API',
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the task (e.g., "pbT5K2OVkkO1M7r5bfsJ6JgAGD5m")',
|
||||
},
|
||||
etag: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ETag value from the task details to update (If-Match header)',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The description of the task',
|
||||
},
|
||||
checklist: {
|
||||
type: 'object',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Checklist items as a JSON object',
|
||||
},
|
||||
references: {
|
||||
type: 'object',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'References as a JSON object',
|
||||
},
|
||||
previewType: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Preview type: automatic, noPreview, checklist, description, or reference',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const taskId = params.taskId?.trim()
|
||||
if (!taskId) {
|
||||
throw new Error('Task ID is required')
|
||||
}
|
||||
return `https://graph.microsoft.com/v1.0/planner/tasks/${taskId}/details`
|
||||
},
|
||||
method: 'PATCH',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
if (!params.etag) {
|
||||
throw new Error('ETag is required for update operations')
|
||||
}
|
||||
|
||||
let cleanedEtag = params.etag.trim()
|
||||
|
||||
logger.info('ETag processing:', {
|
||||
original: params.etag,
|
||||
originalLength: params.etag.length,
|
||||
})
|
||||
|
||||
while (cleanedEtag.startsWith('"') && cleanedEtag.endsWith('"')) {
|
||||
cleanedEtag = cleanedEtag.slice(1, -1)
|
||||
logger.info('Removed surrounding quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (cleanedEtag.includes('\\"')) {
|
||||
cleanedEtag = cleanedEtag.replace(/\\"/g, '"')
|
||||
logger.info('Unescaped quotes:', cleanedEtag)
|
||||
}
|
||||
|
||||
if (!/^W\/".+"$/.test(cleanedEtag)) {
|
||||
logger.warn(
|
||||
'Unexpected ETag format for If-Match. For plannerTaskDetails, use the ETag from GET /planner/tasks/{id}/details.',
|
||||
{
|
||||
cleanedEtag,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
logger.info(`Using If-Match header: ${cleanedEtag}`)
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
'If-Match': cleanedEtag,
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
const body: Record<string, any> = {}
|
||||
|
||||
if (params.description !== undefined) {
|
||||
body.description = params.description
|
||||
}
|
||||
|
||||
if (params.checklist) {
|
||||
try {
|
||||
body.checklist =
|
||||
typeof params.checklist === 'string' ? JSON.parse(params.checklist) : params.checklist
|
||||
} catch {
|
||||
throw new Error('Checklist must be valid JSON')
|
||||
}
|
||||
}
|
||||
|
||||
if (params.references) {
|
||||
try {
|
||||
body.references =
|
||||
typeof params.references === 'string'
|
||||
? JSON.parse(params.references)
|
||||
: params.references
|
||||
} catch {
|
||||
throw new Error('References must be valid JSON')
|
||||
}
|
||||
}
|
||||
|
||||
if (params.previewType) {
|
||||
body.previewType = params.previewType
|
||||
}
|
||||
|
||||
if (Object.keys(body).length === 0) {
|
||||
throw new Error('At least one field must be provided to update')
|
||||
}
|
||||
|
||||
logger.info('Updating task details with body:', body)
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response, params?: MicrosoftPlannerToolParams) => {
|
||||
// Prefer: return=representation requests a body, but the service may still return
|
||||
// 204 No Content for some tenants/requests
|
||||
const text = await response.text()
|
||||
if (!text || text.trim() === '') {
|
||||
logger.info('Update successful but no response body returned (204 No Content)')
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
taskDetails: {} as PlannerTaskDetails,
|
||||
metadata: {
|
||||
taskId: params?.taskId?.trim(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const taskDetails = JSON.parse(text)
|
||||
logger.info('Updated task details:', taskDetails)
|
||||
|
||||
const result: MicrosoftPlannerUpdateTaskDetailsResponse = {
|
||||
success: true,
|
||||
output: {
|
||||
taskDetails,
|
||||
metadata: {
|
||||
taskId: taskDetails.id,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: {
|
||||
type: 'boolean',
|
||||
description: 'Whether the task details were updated successfully',
|
||||
},
|
||||
taskDetails: {
|
||||
type: 'object',
|
||||
description: 'The updated task details object with all properties',
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Metadata including taskId',
|
||||
properties: {
|
||||
taskId: { type: 'string', description: 'Task ID' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user